note 12465 deleted from function.setcookie by sniper
| From: | sniper@php.net | Date: | Wed, 11 Dec 2002 07:13:03 +0000 |
| Subject: | note 12465 deleted from function.setcookie by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40708@lists.php.net to get a copy of this message | ||
A lot of the stuff I was reading here, cookies were not being *saved* between sessions, so if you
quit the browser and re-opened it, the cookie would no longer be there. The following format is the
ONLY thing I could get to work for BOTH netscape AND Internet explorer, that would save cookies.
This is just a test to see if I could get it to work, the following code is not an actual page
I'm using anywhere:
cookie1.php
------------
<form method=GET action=cookie2.php>
Username:
<input type=text name=user size=20>
<input type=submit name=submit>
</form>
------
cookie2.php
-------
header ("Set-Cookie: logged=$user; expires=Friday, 16-Jan-2037 00:00:00 GMT; path=/;");
header ("Refresh: 1; url=cookie3.php");
echo "Logging in please wait...";
------
cookie3.php
-------
$cookieinfo = $HTTP_COOKIE_VARS[logged];
if (isset ($logged)) {
echo "Hello, $cookieinfo. You = sux0rz.";
} else {
echo "You are not logged in.";
}
----------
Besides the ?>'s, I the code above is everything that is in those files. Most of this stuff
is combined tips from all the comments posted here. This is the only combo I could get to work right
for me, thogh. I hope it helps someone else, took me about 4 hours before I got it :)