![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Location: Oxford
Posts: 1
Rep Power: 0
![]() |
On my website, I use cookies. I've put in the script as you should like this:
setcookie.php [PHP]<?php setcookie( "login","IN",time()+36000);?> [/PHP] Then to recall it: getcookie.php [PHP]<?php if ($_COOKIE['login'] == "IN") { $msg = 'Logged in'; } elseif ($_COOKIE['login'] != "IN") { $msg = 'Not logged in'; } else { $msg = 'Error'; } ?> [/PHP] I think this is the right script, but it doesn't set the cookie, even though I've changed browser settings to accept all cookies, and other sites can set cookies, I think it's the script, Thanks very much, George Sephton |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2005
Location: the netherlands
Posts: 11
Rep Power: 0
![]() |
try:
[PHP]$HTTP_COOKIE_VARS['login'][/PHP] |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
you must set the cookie at the very top of the document, before the header information is sent to the browser (before the document type definition). Otherwise, the accessing page must be loaded after the cookie has already been set in order to retrieve it.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|