/    Sign up×
Community /Pin to ProfileBookmark

set cookie to lower level directory??

Hi all

I thought that by making the fourth setcookie() parameter “../” it would make it available on the previous level directory, but alas not. How can this be done? It works fine to set it to a subsequent sub folder, or the entire domain, or the default value (just the current folder), but not for the next level up directory.

Any ideas? Thanks in advance.

p.s. I’ve also tried ‘../../dir’

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@WebfreakMay 26.2004 — I think if you're using / for the path cookie is set for all of directories examle- for www.example.com.

If you want to do this for subdirectory use /somefolder so the path will be www.example.com/somefolder.

You can also check the path of the cookie with [URL=http://www.mozilla.org/firefox]Firefox[/URL] in Tools--> Options--> Privacy--> Cookies--> Sotored Cookies --> And find cookie with your url

I hope it works ?
Copy linkTweet thisAlerts:
@mityaauthorMay 26.2004 — Thanks for that webfreak, though I fear you may have misunderstood me. I can successfully set cookies in subfolders, and in the entire domain via '/'.

What I want to do is set the cookie to a folder in a higher level. So let's say the file which sets the cookie is "folder/folder2/file.php". I want to set the cookie in "folder". I'm aware that this will make it usable in all subfolders of "folder" also.

Thanks again.
Copy linkTweet thisAlerts:
@WebfreakMay 26.2004 — Now i understand what do you want. But i'm afraid this isn't possible. Look description of a path from [URL=http://www.php.net/setcookie]php.net[/URL]:
path-- If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in. [/QUOTE]
Anyone else have any idea? ?
Copy linkTweet thisAlerts:
@mityaauthorMay 26.2004 — Yeah I checked out the php.net bit before posting, seems I can't do what I need to. It seems silly that it's possible to specify a cookie to both a sub folder and to the entire domain, yet not to a folder higher in the directories heirarchy.

Hope Ljubljana's nice today, web freak :o)
×

Success!

Help @mitya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...