Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 18th, 2005, 3:09 PM   #1
sephers
Newbie
 
sephers's Avatar
 
Join Date: May 2005
Location: Oxford
Posts: 1
Rep Power: 0 sephers is on a distinguished road
Question Cookies

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
sephers is offline   Reply With Quote
Old May 19th, 2005, 2:53 AM   #2
medamaybe
Newbie
 
Join Date: May 2005
Location: the netherlands
Posts: 11
Rep Power: 0 medamaybe is on a distinguished road
try:

[PHP]$HTTP_COOKIE_VARS['login'][/PHP]
medamaybe is offline   Reply With Quote
Old Jun 9th, 2005, 11:08 AM   #3
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
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
skuinders is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC