Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetCookie problem

Status
Not open for further replies.

MarlonB

Programmer
Jan 11, 2002
7
NL
Since i went from Apache1/php4.0.6 to apache2/php4.3.4, my SetCookie doesn't work anymore. Only the last call to SetCookie is processed.....

Ex:
SetCookie("LOGON",$set,$expire);
SetCookie("SECLOGON",$pas,$expire);

In this case, only SECLOGON is written.....
I've seen more people complain about this, but haven't found an answer yet :(

 
I'm running PHP 4.3.4 as a module on Apache 2.0.48.

The following code:

Code:
<?php
$set = 'foo';
$pas = 'bar';
$expire = strtotime ('2004-06-01 00:00:00');
SetCookie(&quot;LOGON&quot;,$set,$expire);
SetCookie(&quot;SECLOGON&quot;,$pas,$expire);

print '<html><body><a href=&quot;test_showcookies.php&quot;>click here</a></body></html>';
?>

sets both cookies, as evidenced by clicking on the link pointed to in the output, the script behind which reads:

Code:
<?php
print '<pre>';
print_r ($_COOKIE);
?>

and which outputs:

Code:
Array
(
    [LOGON] => foo
    [SECLOGON] => bar
)

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Pfffttt.....
After two weeks, I find out that it is the expire causing it not to work :(

I use this one: $expire = time() + 365*24*3600;
When i replaced it with yours ($expire = strtotime ('2004-06-01 00:00:00'); ), it immediatly worked :)


 
Yes, i'm using IE.

Never thought of looking into that, as the cookies have worked for 2 years on apache 1 :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top