PHP Cookie and browser refresh confusion -


I have this code and I saw that when I changed the value to something else

Is it related to HTTP titles and super globals? Or something why I have to refresh twice to see the new value Why is not one refreshing? I have tried to read similar questions on other threads but why is it not clear in this way so far? Anyone else is giving me a clear explanation, thanks.

  & lt ;? Php $ name = "test"; $ Value = "Hello"; $ End = time () + (60 * 60 * 24 * 7); Setkey ($ name, $ value, $ end); ? & Gt; & Lt ;! DOCTYPE html & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt; Title & gt; PHP & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php $ test = isset ($ _COOKIE ["test"])? $ _COOKIE ["Trial"]: ""; Resonance $ test; ? & Gt; & Lt; / Body & gt;  

So if I change the value to say 500 then I need to refresh twice to see the new value on the page.

The answer is here.

Try to refresh your page programmatically. Example:

  & lt ;? Php if (isset ($ _ cookie ['test'])) {echo 'cookie =', $ _COOKIE ['test']; } Else {setcookie ('test', 'my-cookie-value', strtotime ('+ 1 day')); If (! Isset ($ _gET ['setcookie'])) {Header ('Refresh: 0; url =? Setcookie =' ';); } Else {Resonant 'Your browser does not accept cookies!'; }}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -