Using PHP cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cksonline
Forum Newbie
Posts: 2
Joined: Sat Jan 10, 2009 4:40 am

Using PHP cookies

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Using PHP cookies

Post 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.
cksonline
Forum Newbie
Posts: 2
Joined: Sat Jan 10, 2009 4:40 am

Re: Using PHP cookies

Post by cksonline »

thankx tasairis... :)
Post Reply