Page 1 of 1
cookie not getting set
Posted: Fri Oct 01, 2010 2:06 pm
by cneeds
Hi
I'm setting a cookie at the top of fileA.php:
Code: Select all
<?php
setcookie('client_internal_ID', $_GET['client_internal_ID'], 0, "/");
fileA.php calls fileB.php with:
Code: Select all
<form name="AADform" method="post" id="userform" action="fileB.php">
When I retrieve 'client_internal_ID' from $_COOKIE it has a value that it was set to a few days ago. Does anybody have an idea of what I've broken?
Here is the code in fileB.php:
Code: Select all
echo("client_internal_ID=".$_COOKIE['client_internal_ID']);
Chris
Re: cookie not getting set
Posted: Fri Oct 01, 2010 5:48 pm
by cneeds
Maybe it's a name thing? Can $_GET['client_internal_ID'] and $_COOKIE['client_internal_ID'] exist at the same time?
Chris
Re: cookie not getting set
Posted: Fri Oct 01, 2010 5:56 pm
by DigitalMind
cneeds wrote:Can $_GET['client_internal_ID'] and $_COOKIE['client_internal_ID'] exist at the same time?
Yes
Re: cookie not getting set
Posted: Fri Oct 01, 2010 7:23 pm
by califdon
In your post there are html entities, like
& # 4 0 ; (I had to space them out so they wouldn't be changed to just "(" ) -- are these artifacts of your copying and pasting?? If they are in your code, I imagine that's your problem. That's unacceptable as PHP code. Your code should look like this:
Code: Select all
setcookie('client_internal_ID', $_GET['client_internal_ID'], 0, "/");
Re: cookie not getting set
Posted: Sat Oct 02, 2010 8:24 am
by cneeds
sorry about the copy n paste heiroglyphics, I didn't notice until you pointed it out... Oops, how do I stop that from happening? Pass it through notepad or something?
___
I'm really stuck on this one. ran out out ideas completely...
Re: cookie not getting set
Posted: Sat Oct 02, 2010 9:40 am
by cneeds
califdon wrote:In your post there are html entities, like
& # 4 0 ; (I had to space them out so they wouldn't be changed to just "(" ) -- are these artifacts of your copying and pasting?? If they are in your code, I imagine that's your problem. That's unacceptable as PHP code. Your code should look like this:
Code: Select all
setcookie('client_internal_ID', $_GET['client_internal_ID'], 0, "/");
Sorry, I had the wrong tags...
Chris
Re: cookie not getting set
Posted: Mon Oct 04, 2010 10:30 am
by cneeds
I found the problem.
I was unsetting the cookie with the unset command but that wasn't destroying the cookie so I had to setcookie("client_internal_ID","",time() - 60*60);
to really clear it!
Chris