SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: cookie quickie
-
Jan 31, 2003, 15:14 #1
- Join Date
- Mar 2001
- Location
- Southern California, USA
- Posts
- 1,181
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
cookie quickie
Need help with cookie
Hi,
In the a.php I have:
$wT= time()+3600*24*365;
$s = $_POST['zone'];
setCookie("tZone", $s, $wT);
echo $_COOKIE['tZone']; //echo out for test then comment it
//and I header() right here to go to b.php
and it does echo the cookie value above in a.php. But in b.php, the very first line I try to echo out value:
echo $_COOKIE['tZone'];
Nothing's displayed. Why?
(I'm using IE6,notebook, winXP Pro)
Thanks,
John
-
Feb 3, 2003, 04:41 #2
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
On page a.php why not output the value of $s and see if there is actually anything in it. Also, you may want to try and check if the cookie is actually getting set:
PHP Code:if (!setcooke("tZone", $s, $wT)) {
echo "Failed!
}
-
Feb 3, 2003, 14:19 #3
- Join Date
- Mar 2001
- Location
- Southern California, USA
- Posts
- 1,181
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you. I think I've got it. I did different way by setcookie in the same b.php. but I think that's not the problem. The prolem probably is:
setCookie("tZone", $s, $wT);
and
setCookie("tZone", $s, $wT, $dir, $path,0);
are different. There are 2 cookies that has same names 'tZone' here!, and the script may use the old variable, so it doesn't work. Delete the unwanted cookie and problem solved.
Bookmarks