Welcome Guest, Not a member yet? Register   Sign In
Two CI apps, same domain, overlapping sessions
#1

[eluser]louis w[/eluser]
I have two CI applications installed on my local computer and it appears that their session data is being shared between the two.

Is there a built in way to restrict session data to only be available in it's own app? Adding apppath to the encryption or something.

This seems like it could cause potential problems.

Thanks.
#2

[eluser]dannyded[/eluser]
I have same problem.. Don't have solution yet.. Anyone else?
#3

[eluser]narkaT[/eluser]
try to change the 'sess_cookie_name' in you config.php Wink
#4

[eluser]dannyded[/eluser]
I'm using $config['sess_use_database'] = TRUE, so cookie_name should be irrelevant.
#5

[eluser]Jamie Rumbelow[/eluser]
The session class still stores a bit of data in the cookie, so set it anyway.
#6

[eluser]OwanH[/eluser]
louis, what are the URLs of these two local CI apps? Remember that CI's Session class still uses cookies to store at a minimum the session ID, even if you are storing your session data in a database. If the two apps reside on the same domain, whether local or live, then the sessions will overlap. As narkaT suggests, you should set the 'sess_cookie_name' in your config.php to something different for each app.
#7

[eluser]louis w[/eluser]
[quote author="narkaT" date="1229661684"]try to change the 'sess_cookie_name' in you config.php Wink[/quote]

DOH! Yea I should have thought of that. Thanks.

I also think that using the BASEPATH variable to set the cookie_path dynamically would allow me to copy/install my CI application in different projects without having to manually customize the config each time.
#8

[eluser]louis w[/eluser]
Update:

I had this constant definition in my index.php file which sets a SITEPATH variable to reference the root directory of my website project which I was using for some other things like setting asset paths.

Code:
define('SITEPATH', (dirname($_SERVER['SCRIPT_NAME']) == '/') ? '/' : dirname($_SERVER['SCRIPT_NAME']).'/');

By changing cookie_directory to use this instead, I am able to prevent overlapping sessions when they have the same name for different projects on localhost.
#9

[eluser]OwanH[/eluser]
Glad to know you got it worked out Smile.




Theme © iAndrew 2016 - Forum software by © MyBB