Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.