I have a script where a cookie is set and recalled on the same page.
The problem is, I can only recall the variable if the page is refreshed after the cookie is set.
Any ideas?
Cookie Problem
Moderator: General Moderators
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
This is normal behaviour see:
http://nl2.php.net/manual/en/function.setcookie.php
http://nl2.php.net/manual/en/function.setcookie.php
Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.