|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-27 12:43 UTC] kris dot wilkinson at titancs dot com
The problem is simple, in the older versions of php, you could set a cookie and have it available for your specified amount of time from any browser window open.
The line was as follows :
setcookie ("myCookie","Blah","time()+7201");
The cookie should be set for just over 2 hours.
In 4.0.6, If you set the cookie, the time you set is never actually used, and the cookie is destroyed immediately after you close the browser window.
Another downside, you cannot access this cookie from another window even if the original window is open. this sounds like an exclusive window session is linked to that cookie, and once the uplink is dropped, so is the cookie.
To access the cookie, i've been using :
$mycookie = $HTTP_COOKIE_VARS[myCookie];
it will show up in the original window, but not in others.
at all!
what's up?! :)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
setcookie ("myCookie","Blah","time()+7201"); ^ ^ do you realy have quotes here? -> "time()+7201" as a string would evaluate as zero, so deleting the ccokie instead of setting ityes there are quotes in the line. If you remove the quotes, the cookie doesn't initialize at all. Should we be assigning a variable there instead for example : $mytime = time() + 7200; setcookie ("coookiename", "cookievalue", $mytime); ? There have been tones of posts in your setcookie function information about the cookie not working at all if you do not put the "" in there.setcookie ('CookieName', 'CookieValue', time()+7200); works. If not you're doing something wrong. This is NOT a bug in PHP. Ask further support-questions on the appropriate mailinglist (php-general@lists.php.net).Not to sound offensive, have you actually tried it? I've pasted exactly what you just sent back to me, and it wont go. There have been many comments in the newsgroups and the function page itself about this issue ... people are having to put quotations around the time aspect in order to get it to work at all, and according to you, that would set the value to zero right? -> cookie.php <?php setcookie ('CookieName', 'CookieValue', time()+7200); header ("Location: cookie2.php"); ?> -> cookie2.php <?php $cookie = $HTTP_COOKIE_VARS[CookieName]; echo $cookie; ?> that's exactly the test script i'm using. Is there anything wrong with the above?array(4) { ["xfxdD"]=> string(4) "Blah" ["wingrep"]=> array(4) { ["customer_cookie"]=> string(10) "1150232722" ["customer_id"]=> string(1) "1" ["customer_name"]=> string(13) "Mr. Wilkinson" ["customer_province"]=> string(2) "BC" } ["titancart"]=> array(1) { [0]=> string(72) "33a63c7718-component-1715-108.95-1-Adaptec Fireconnect 4300 3 Port-2.00*" } ["wingrepship"]=> array(7) { ["ship_to"]=> string(18) "Mr. Kris Wilkinson" ["unit_type"]=> string(5) "SUITE" ["unit_num"]=> string(3) "101" ["street"]=> string(18) "10464 176th Street" ["city"]=> string(8) "Edmonton" ["province"]=> string(2) "BC" ["postal"]=> string(7) "T5R 3L6" } } is what it returns. nothing containing the CustomerCookie defined previously. these other values are from original cookies which had the "" around the time aspect. so i'm assuming this means that the value was not stored in a cookie at all?array(4) { ["xfxdD"]=> string(4) "Blah" ["wingrep"]=> array(4) { ["customer_cookie"]=> string(10) "1150232722" ["customer_id"]=> string(1) "1" ["customer_name"]=> string(13) "Mr. Wilkinson" ["customer_province"]=> string(2) "BC" } ["titancart"]=> array(1) { [0]=> string(72) "33a63c7718-component-1715-108.95-1-Adaptec Fireconnect 4300 3 Port-2.00*" } ["wingrepship"]=> array(7) { ["ship_to"]=> string(18) "Mr. Kris Wilkinson" ["unit_type"]=> string(5) "SUITE" ["unit_num"]=> string(3) "101" ["street"]=> string(18) "10464 176th Street" ["city"]=> string(8) "Edmonton" ["province"]=> string(2) "BC" ["postal"]=> string(7) "T5R 3L6" } } is what it returns. nothing containing the CustomerCookie defined previously. these other values are from original cookies which had the "" around the time aspect. so i'm assuming this means that the value was not stored in a cookie at all?$SessionID = md5(uniqid("")); SetCookie("sigla_cookie", $loginname, time()+3600, $DIRECTORY); SetCookie("SessionID", $SessionID, time()+3600, $DIRECTORY); The first is not send at all, I traced the tcpdump. The second is send normaly. If I change order, I stil get the second a do not get the first. The same script on other machine PHP 4.2.2 works. PHP 4.0.6 Server version: Apache/1.3.20 (Unix) (Red-Hat/Linux) Server built: Sep 5 2001 23:12:29$SessionID = md5(uniqid("")); SetCookie("sigla_cookie", $loginname, time()+3600, $DIRECTORY); SetCookie("SessionID", $SessionID, time()+3600, $DIRECTORY); The first is not send at all, I traced the tcpdump. The second is send normaly. If I change order, I stil get the second a do not get the first. The same script on other machine PHP 4.2.2 works. PHP 4.0.6 Server version: Apache/1.3.20 (Unix) (Red-Hat/Linux) Server built: Sep 5 2001 23:12:29