Welcome Guest, Not a member yet? Register   Sign In
Two CI in one site - messing each other's session variables
#1

[eluser]mDonchev[/eluser]
Hello,

I have two parts of a website both written with separate CI installations (dont ask why!).
The problem is that they are "erasing" each other's session variables when you jump from one to another.

Can you tell me if there is something I can write in the config or do something else to prevent from such crossing in the sessions.

THanks in advance
Martin
#2

[eluser]Tom Schlick[/eluser]
in the config file change the cookie prefix. that should take care of it.
#3

[eluser]mDonchev[/eluser]
Dude,

Thanks a lot. That really solved the problem.

Thanks again.

Martin
#4

[eluser]louis w[/eluser]
Even better yet you should set the cookie_path in the config. By default this will be "/". If you have two sites on the same domain a cookie path of / will make the cookies available to both. Normally you set a cookie path to the sub directory your site is in and the cookies will only be available to scripts in that directory. This is built in cookie security.

I dynamically populate this with the directory my index.php resides in.


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


// config.php
$config['cookie_path']        = SITEPATH;

Having a variable containing the working directory of my site (SITEPATH) comes in very handy.
#5

[eluser]mDonchev[/eluser]
Thanks man,

I will keep that in mind for the future.

THat will be really handy indeed.

THanks
Martin




Theme © iAndrew 2016 - Forum software by © MyBB