Warning: Reading this may make you smile and/or laugh or/at very least chuckle. Mild humor injected for your benefit. Making you smile is my way of showing gratitude for your time.
The cookie is being set
successfully, or is it?
setcookie("REF", $referer, strtotime( '+30 days' ) );
print_r($_COOKIE);
When coming from a referring site, I get [REF] => site
, which is working properly. Next, I open a new tab and go to the URL directly. Again, I get [REF] => site
- great it appears to be working!
But wait, don't get too excited. That "appearance" of it working is apparently misleading. It's an illusion; deja-vu of that damned kool-aid machine in the dessert --- all over again. Anyways, I hit f5
and refresh the page and now the madness begins.
Guess what happens? Did you guess? Here, I'll just tell you; the cookie is no longer set. Array()
is empty. What the frick?
Tested in Chrome and Firefox and the result is the same in both.
Question:
How do I make the cookie persist until expired? Why/How does refreshing the page break the cookie? Bonus: Is it possible for a cookie set in Chrome
to automatically be set in Firefox
? (I'm assuming, NO way! But sometimes I like to think ANYTHING is possible)