note 14648 added to function.setcookie.php
| From: | raynet at edu dot lahti dot fi | Date: | Tue, 07 Aug 2001 23:24:56 +0000 |
| Subject: | note 14648 added to function.setcookie.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16454@lists.php.net to get a copy of this message | ||
The well know "two-dots" issue with cookie domains might be solvable by using the correct
domain name, eg:
slashdot.org.
instead of
slashdot.org
the last dot is actually the root domain.
Also I've noticed no problems with cookies when I'm using the form:
setcookie("variablename","$variable");
In my opinion there is no need for the expiration field, or any other fields. Just do the stuff on
the server. Example:
$session_id = md5(uniqid(rand()));
<add $session_id to database with all the parameters/variables you are using>
setcookie("session_id",$session_id);
setcookie("session_exp",time()+3600);
The just fail the cookie if $session_exp is expired. Also you can leave the expire cookie because
you can store this information to DB.
Don't send plaintext in cookies, it just invites crackers to exploit your site.
http://www.php.net/manual/en/function.setcookie.php