session 'range' ? |
[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 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 Thanks in advance!
[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_";
[eluser]stijnvdb[/eluser]
FrankieShakes, that was my first guess, too I'll just paste the snippets from both config files here: Demo: Code: $config['cookie_prefix'] = "adv_"; Personal: Code: $config['cookie_prefix'] = "vdb_"; Thanks for replying btw edit: whoops, missed the path-part you mentioned, I'll try it right now
[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.
[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.
[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.
[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... here's what I have: Demo: Code: $config['cookie_prefix'] = "adv_"; Personal: Code: $config['cookie_prefix'] = "vdb_"; 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!
[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
[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... :/
[eluser]stijnvdb[/eluser]
okay, problem solved! all I had to do was add the param for the domain: Code: session_set_cookie_params(0 , '/stijn/', '.joske.mynobix.net') and done thanks for helping me out guys! And thanks for the link to that topic Rick, that's the one that helped me find it |
Welcome Guest, Not a member yet? Register Sign In |