Jump to content

Cookie is getting stored in two different locations how to force to be only one?


ghurty

Recommended Posts

Hi

I am have two different pages on my website that I want to access the same cookie, but for some reason, the cookies are getting stored in two different locations.

1) www.mysite.com

2) www.mysite.com/calender

 

Is there a way I can force the cookie to be written/looked for in a particular location?

 

This problem I am having is only with Internet Explorer, in firefox the cookies are stored and read from perfectly.

 

Here is the script I am using to read/write the cookie. It is the exact same on both pages.

if(isset($_GET['activelocation'])){
$activelocation = $_GET['activelocation'];
setcookie('location', $activelocation, time()+60*60*24*30);
} elseif(isset($_COOKIE['location'])){
$activelocation = $_COOKIE['location']; //if the cookie is set, get the value
} else{
setcookie('location', 'New York, NY', time()+60*60*24*30);
$activelocation = "New York, NY";
}

 

Thanks

bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]]] )

 

You can set the path using "string $path".

 

Can you give me an example how to phrase the "string $path" variable?

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.