niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » PHP
How to set a session cookie with a path?
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
John Drako
*nix forums beginner


Joined: 16 Feb 2005
Posts: 7

PostPosted: Thu Jul 20, 2006 7:32 pm    Post subject: How to set a session cookie with a path? Reply with quote

I need to set a session cookie (expires when the browser closes) with a
path of "/".

Is there a way to do it?

I tried:

setcookie("cookie_name", $cookie_value, "", "/");

and

setcookie("cookie_name", $cookie_value, "0", "/");

and of course none of them worked.

I can't move the page that is setting the cookie to the top level
directory of the site, but I need the cookie to be available to couple
of page there.

Is this doable at all?

TIA
Back to top
Janwillem Borleffs
*nix forums Guru


Joined: 20 Feb 2005
Posts: 404

PostPosted: Thu Jul 20, 2006 8:29 pm    Post subject: Re: How to set a session cookie with a path? Reply with quote

John Drako wrote:
Quote:
I tried:

setcookie("cookie_name", $cookie_value, "", "/");

and

setcookie("cookie_name", $cookie_value, "0", "/");

and of course none of them worked.


The manual says:

"Because the expire argument is integer, it cannot be skipped with an empty
string, use a zero (0) instead"

So, do not use "0" but 0.

When working between subdomains of the same father domain, you should also
supply the fifth argument with a value of ".yourdomain.com" (mind the
preceding dot).


JW
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 7:12 pm | All times are GMT
navigation Forum index » Programming » PHP
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts HOW-TO: Deliver many messages over 1 smtp session? Oymakoon Postfix 0 Thu Mar 20, 2008 11:12 am
No new posts User Environment - export PATH variable paalepu AIX 0 Tue Sep 12, 2006 8:12 pm
No new posts long path names for ifstream in( Fred J. C++ 1 Thu Jul 20, 2006 2:06 am
No new posts smbmount: 20381: session request to *SMBSERVER failed (No... lunc networking 0 Wed Jul 19, 2006 10:52 am
No new posts DECnet session timeout Brian VMS 3 Wed Jul 19, 2006 1:01 am

Refinance | Loans | Loan | Loans | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3493s ][ Queries: 16 (0.0929s) ][ GZIP on - Debug on ]