IIS & Cookies
Moderator: General Moderators
IIS & Cookies
Hi guys, I seem to be able to set cookies with IIS, but not read them. I've been trying if (!$cookiename). Am I doing something wrong. Is there a way to pull the fields out of the cookie? Honestly, I am a rank beginner and would appreciate some pointers.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Have a read of this:
viewtopic.php?t=511
You probably need to be using:
Mac
viewtopic.php?t=511
You probably need to be using:
Code: Select all
if (!isset($_COOKIE['cookiename'])) {I use
setcookie("cookiename",$user,time()+(90*90*12),'sitename');
then to read it I have
if (!isset($_COOKIE["cookiename"]))
{ go to unauthorized page;
} else { do these things }
I have verified the cookie is being written. But I cannot get the second part of the code to work.
FYI - Unsure if this in related but I also cannot get session variables to be read either. I have checked and session.save_path is fine.
update: echo $_COOKIE['cookiename'] doesn't work. I get an error that says Undefined index: dmvalid in C:\Inetpub\clients\dm\htdocs\rulespost.php on line 1.
setcookie("cookiename",$user,time()+(90*90*12),'sitename');
then to read it I have
if (!isset($_COOKIE["cookiename"]))
{ go to unauthorized page;
} else { do these things }
I have verified the cookie is being written. But I cannot get the second part of the code to work.
FYI - Unsure if this in related but I also cannot get session variables to be read either. I have checked and session.save_path is fine.
update: echo $_COOKIE['cookiename'] doesn't work. I get an error that says Undefined index: dmvalid in C:\Inetpub\clients\dm\htdocs\rulespost.php on line 1.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
There's a bunch of things you need to be aware of when setting cookies - have you read this in the manual:
MacPHP manual wrote:Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK