CodeIgniter Forums
session 'range' ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: session 'range' ? (/showthread.php?tid=2554)



session 'range' ? - El Forum - 08-12-2007

[eluser]stijnvdb[/eluser]
Hi,

probably a stupid question, but can't seem to find anything about it in the user guide...
I'm building my own cms-system, which means: admin functionalities.
My personal website is built with my CMS, and I'm running a demo of the CMS on the same server, so I have 2 CI installations in 2 different dirs Smile
Now, the problem here is that my sessions don't quite get it... ;-)

The problem: if you would log in to the demo-adminpanel, you'd also have adminrights on the adminpanel of my personal website... Not good. This is how I check logged in true/false in both systems:
Code:
<? if ($this->session->userdata('logged_in') == 1)  : ?>

Is there some config parameter that allows you to keep session vars within a certain environment (without having to edit the if-statement everywhere) ? I'm using native sessions btw Smile

Thanks in advance!


session 'range' ? - El Forum - 08-12-2007

[eluser]FrankieShakes[/eluser]
stijnvdb,

My guess would be that your Cookie's "path" setting is the same for both applications:

Code:
$config['cookie_path']        = "/";

Try setting the cookie_path for each cookie to a different location (ie: the location of the application)... Also, you might want to give the "cookie_prefix" unique values as well, so you don't have any collision between the two:

Demo CMS:
Code:
$config['cookie_prefix']    = "demo_";

Personal CMS:
Code:
$config['cookie_prefix']    = "stijnvdb_";



session 'range' ? - El Forum - 08-12-2007

[eluser]stijnvdb[/eluser]
FrankieShakes,

that was my first guess, too Smile
I'll just paste the snippets from both config files here:

Demo:

Code:
$config['cookie_prefix']    = "adv_";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

Personal:

Code:
$config['cookie_prefix']    = "vdb_";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

Thanks for replying btw Smile

edit: whoops, missed the path-part you mentioned, I'll try it right now Smile


session 'range' ? - El Forum - 08-12-2007

[eluser]FrankieShakes[/eluser]
stijnvdb,

No problem... Hopefully we'll figure out why this isn't working for you. Another to look at, what does this line (in config/config.php) look like in both apps:

Code:
$config['sess_cookie_name']        = 'ci_session';

Is it possible they're both using the same name? If so, try giving them different session names. That could also be the cause.


session 'range' ? - El Forum - 08-12-2007

[eluser]stijnvdb[/eluser]
FrankieShakes,

personal:
Code:
$config['sess_cookie_name']        = 'vdb_sessions'

demo:
Code:
$config['sess_cookie_name']        = 'adv_sessions';

also, the path-thingy didn't seem to work... Maybe my input is wrong? I tried the full http-links with trailing slash (and without), and the dir-names.


session 'range' ? - El Forum - 08-12-2007

[eluser]Michael Wales[/eluser]
It's because when cookie_path is set to / the cookie is established across the entire domain. From the PHP manual for setcookie():

Quote:The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.



session 'range' ? - El Forum - 08-12-2007

[eluser]stijnvdb[/eluser]
I understand... Weird, even when I set it to the right dir it doesn't work... :/ It just keeps setting them globally... Confused here's what I have:

Demo:
Code:
$config['cookie_prefix']    = "adv_";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/advanced/";

Personal:
Code:
$config['cookie_prefix']    = "vdb_";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/stijn/";

I've also tried defining the cookie domain along with the path, but that didn't do it either...

...And thanks for helping me out guys! Smile


session 'range' ? - El Forum - 08-12-2007

[eluser]Rick Jolly[/eluser]
I don't think Native Sessions uses the config file. Have a look here:
http://ellislab.com/forums/viewthread/57101/#280830


session 'range' ? - El Forum - 08-13-2007

[eluser]stijnvdb[/eluser]
Still can't get this to work... :/
I added the following line in the Session library:
Code:
session_set_cookie_params (0, '/stijn/')

but it still stretches out over the entire domain... :/


session 'range' ? - El Forum - 08-14-2007

[eluser]stijnvdb[/eluser]
okay, problem solved! Smile
all I had to do was add the param for the domain:

Code:
session_set_cookie_params(0 , '/stijn/', '.joske.mynobix.net')

and done Smile

thanks for helping me out guys!
And thanks for the link to that topic Rick, that's the one that helped me find it Smile