Page 1 of 1

Using PHP cookies

Posted: Sat Jan 10, 2009 4:43 am
by cksonline
Hi all,

I have some issue using cookies in PHP. As it seems very easy to use cookies with php

I am using setcookie(name, value, expire, path, domain); function to set cookie and retrieve its value using $_COOKIE superglobal variable

I want to set cookie in my sub folder like panel and access it in root folder. As we can set the cookie in sub folder using the path. But how can we access cookie from root which is set to a sub folder.

Means to access cookie of some sub folder at root of website.

br
cksonline

Re: Using PHP cookies

Posted: Sat Jan 10, 2009 5:35 am
by requinix
The "path" isn't where the cookie is being set but where it should be available. If you use path=/folder only files located somewhere in /folder (could be a subdirectory, or a sub-subdirectory...) can get to that cookie.

Just use / for the path.

Re: Using PHP cookies

Posted: Sat Jan 10, 2009 5:58 am
by cksonline
thankx tasairis... :)