PHP Session

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
kerepuki
Forum Commoner
Posts: 30
Joined: Fri Oct 29, 2004 12:28 am

PHP Session

Post by kerepuki »

Hi everyone,

I have a small problem. I am developing applications which use sessions. Now these applications will live in a sub folders off the main domain ie. http://xxxxx.com/app1, http://xxxxx.com/app2, http://xxxxx.com/app3 etc.

Now when I start the session and retrieve information for the user against the session, I can get the same information in each of the apps. This is not what I want. I would like all cart info in http://xxxxx.com/app1 to be different to all cart info in http://xxxxx.com/app2.

I am setting the sessions like $_SESSION['app1']['cartID'], $_SESSION['app2']['cartID'] which I assume is fine however PHP is setting the same value because I imagine it is getting the cartID from http://xxxxx.com.

Please help, very important.

Thanks
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: PHP Session

Post by Mordred »

session_set_cookie_params
kerepuki
Forum Commoner
Posts: 30
Joined: Fri Oct 29, 2004 12:28 am

Re: PHP Session

Post by kerepuki »

Thanks for the reply however everything I have tried doesnt work. It all seems to be relating to app1.xxx.com, app2.xxx.com.

Can you please post a sample?

What I have tried are:
session_set_cookie_params(60*60*24*5, "/app1/", "xxx.com");
session_set_cookie_params(60*60*24*5, "/app1", "xxx.com");
session_set_cookie_params(60*60*24*5, "app1", "xxx.com");

Plus all other combinations using slash '/' in domain and path.

Thanks
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: PHP Session

Post by Mordred »

How about this:
session_set_cookie_params(60*60*24*5, "/app1/", " .xxx.com");
(no time to test it, sorry)
Post Reply