Jump to content

[SOLVED] session_start(); problem


bofett

Recommended Posts

I have a site which has identical sub sites but for different regions.  For example...

 

www.site.com/us/ca/sitea

www.site.com/us/az/siteb

www.site.com/us/nv/sitec

 

Each site has a different name and DB, most likely different users.  My problem is that if a user logs into sitea and then goes to siteb (without logging off), the system gets confused and may see them as a different user.  Its like the session is being set for the main url of www.site.com.  This allows access to the wrong user information.  Is there a way to assign an additional value (like ca or nv) to session_start(); for each site?  Or can you have the session set with more url info like www.site.com/us/ca/?

 

Thanks for the help. 

Link to comment
https://forums.phpfreaks.com/topic/160512-solved-session_start-problem/
Share on other sites

You need to set the session cookie path to /

 

ref: http://us.php.net/manual/en/session.configuration.php#ini.session.cookie-path

 

Thank you for your reply.  Should I set this in my php file before session_start(); by using ini_set( 'session.cookie_path', '/' ); or in php.ini with session.cookie_path = /?  Also, can or should I use a variable which showes which url like us/ca or us/nv?  I am asking because I have been trying it different ways and it is still not working.

Thanks again.

I have been able to make it work in Firefox with this code but IE8 doesent seem to be setting a cookie so its not working in IE8?

 

        include("config.php");
        ini_set('session.cookie_path', '/'.$sitest.'/');
        session_start();

 

config code...

$sitest = "us/ca";

 

I appreciate any help on this.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.