Note that there are some explanatory texts on larger screens.

plurals
  1. POI can't set cookies in php
    primarykey
    data
    text
    <p>Right then, I seem to have misunderstood something about cookies. Why doesn't this work...</p> <pre><code>&lt;?php if (isset($_COOKIE["stop"])){ echo "Welcome " . $_COOKIE["stop"] . "!&lt;br /&gt;"; } $passedvar = $_POST["stopsaway"]; if (isset($passedvar)){ echo "HHHYES!!!"; if (is_numeric($passedvar)){ echo "Yup its a number string alright! I'll turn it into a int and I'll make a cookie."; //$passedvar = (int)$passedvar; setcookie("stop", $passedvar, time()+30); echo "COOKIE MADE."; } } if (isset($_COOKIE["stop"])){ echo "Welcome " . $_COOKIE["stop"] . "!&lt;br /&gt;"; } //var_dump($_POST["stopsaway"]); ?&gt; </code></pre> <p>SECOND CODE</p> <pre><code>&lt;?php $thing = 1; if ($thing==1){ setcookie("stop","4",time()+30); } if (isset($_COOKIE["stop"])){ echo "So why won't it work THERE!?"; } print_r($_COOKIE); ?&gt; </code></pre> <p>Basically, I want the user to enter a number into a field, and then a cookie is set to that number, and the main page reflects that change. This worked ONCE. The bottom code seems to work, but for some reason it doesn't work unless I manually type in the url to go to the main page using the cookie page window. If I have the two tabs open next to eachother...it doesn't do anything just to refresh the main page after creating the cookie....I wonder why.</p> <p>Also, I remember hearing that nothing can come before setcookie, for it to work it has to be the very first line of code..... So then how am I supposed to check the input first, or other conditionals? Thanks! Oh right, and I'm using Firefox, but I've tested on my Android as well. And it's working on one page but not another so I don't think it's the browser.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload