View Full Version : Cookie only working in one directory.
11-09-2006, 05:37 AM
I have a cookie set with these (very limited) parameters
setcookie ('username2', $username);
Currently if I call that via PHP
, it only works in my "/login/" directory and not my main directory.
What addl parameters do I need to add to that so it will work everywhere?
(I bet this is something very simple)
setcookie('username2', $username, '/', 'MyWebsite.com'); didn't work.
11-09-2006, 10:19 AM
which directory is it being set it try
$value = "Test cookie";
setcookie("TestCookie", $value, time()+60*60*24*30); /* expire in 30 days */
setcookie('TestCookie', $value, time()+3600, '/', '.mysite.com'); /* expire in 1 hour and set for all directory's on your web server and all subdomains*/
11-09-2006, 03:36 PM
alright, that works..
but I've been having trouble finding out how to set the time syntax to expire at end of session without not including it..
11-09-2006, 04:03 PM
just leave it out?
nothing between the commas?
11-10-2006, 01:16 AM
See if I do
setcookie ('username2', $username, , '/', '.mysite.org');
Parse error: syntax error, unexpected ',' on line 44
11-10-2006, 01:45 PM
setcookie ('username2', $username, '', '/', '.mysite.org');
there needs to be info to tell php your not limiting it
if you leave
setcookie ('username2', $username, , , '.mysite.com');
its not gonna know the directory or time to set
11-10-2006, 03:18 PM
oops ... Rafiki is right ...
I think I forgot the ,' ',
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.