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!

Reading cookie in other directory...

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi. Is it possible to read cookies that were set in another directory?

i.e one was made in but I want to read it in I tried accessing it via the variable (i.e. $COOKIE_NAME), but that came up as blank.

Any help would be apprecited :)

Andy
 
as i can remember, cookies are readable only in the origin dir and it's subdirs, so there's no way how to read your cookie under test.com
 
If you specify a path of "/", it is theoretically available to the entire site. If you do not specify a path, the path is assumed to be the document you are hitting when the cookie is set.

That is, according to Netscape, who invented cookies. You browser's mileage may vary.
 
Could you provide an example of the path thing please sleipnir? I'm not quite sure where it should go/in what format.

Thanks

Andy
 
To make a cookie named "foo" with value "bar" that will expire in one hour available to any page in a web site at "
setcookie ("foo", "bar", time()+3600, "/", "

To make a cookie named "foo" with value "bar" that will expire in one hour available to any page in the "admin" directory and below in a web site at "
setcookie ("foo", "bar", time()+3600, "/admin", "
With this last example, the browser should make the cookie "foo" available to the server when at the URL and at but not at nor at
Netscape's cookie spec states that if you do not specify a path, the browser must assume that it was intended only for the page that was retrieved when the cookie was set.

Point your browser to
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top