Re: problems with cookies and PHP
| From: | Rick Emery | Date: | Thu, 13 Feb 2003 20:11:59 +0000 |
| Subject: | Re: problems with cookies and PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135511@lists.php.net to get a copy of this message | ||
In your code, it appears you are attempting to determine the value of the cookie immediately upon
setting. The value of the cookie is NOT available at this point; a new page must be opened.
Why are you setting time to 0? If you want cookie to disappear at end of the session, use NULL.
Are you certain that $_COOKIE[] is available to you? have you tried $HTTP_COOKIE_VARS[]?
Your code ends with two braces ( } ); why? It should end with a single brace.
----- Original Message -----
From: "Joshua Chapman" <webmaster@faxonautolit.com>
To: <php-general@lists.php.net>
Sent: Thursday, February 13, 2003 12:57 PM
Subject: [PHP] problems with cookies and PHP
This is driving me nuts... it won't set or reset the cookie
no errors no nothing...
I've learned quite a bit about cookies and PHP thus far but something important must still be
eluding me. I've read the manual entry on it, is there any other tutorial out there that's
better?
what am I doing wrong?
<?php
if(!isset($_COOKIE['userInfo'])){
setcookie("userInfo","temp",0,"/","faxonautoliterature.com",0);
print "set temp";
}else{
if($_COOKIE['userInfo']=="temp"){
setcookie("userInfo","userID",time()+60*60*24*30,"/","faxonautoliterature.com",0);
print "set info";
}
}
?>