ghurty Posted August 12, 2007 Share Posted August 12, 2007 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 Link to comment https://forums.phpfreaks.com/topic/64564-cookie-is-getting-stored-in-two-different-locations-how-to-force-to-be-only-one/ Share on other sites More sharing options...
NArc0t1c Posted August 12, 2007 Share Posted August 12, 2007 bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]]] ) You can set the path using "string $path". Link to comment https://forums.phpfreaks.com/topic/64564-cookie-is-getting-stored-in-two-different-locations-how-to-force-to-be-only-one/#findComment-321830 Share on other sites More sharing options...
keeB Posted August 12, 2007 Share Posted August 12, 2007 Why not use Sessions? http://php.net/sessions Link to comment https://forums.phpfreaks.com/topic/64564-cookie-is-getting-stored-in-two-different-locations-how-to-force-to-be-only-one/#findComment-321840 Share on other sites More sharing options...
ghurty Posted August 12, 2007 Author Share Posted August 12, 2007 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 Link to comment https://forums.phpfreaks.com/topic/64564-cookie-is-getting-stored-in-two-different-locations-how-to-force-to-be-only-one/#findComment-321866 Share on other sites More sharing options...
NArc0t1c Posted August 12, 2007 Share Posted August 12, 2007 http://za.php.net/setcookie <?php setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1); ?> Link to comment https://forums.phpfreaks.com/topic/64564-cookie-is-getting-stored-in-two-different-locations-how-to-force-to-be-only-one/#findComment-321869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.