Welcome Guest, Not a member yet? Register   Sign In
cookie/session expiration time

Hi all,

i'm already using a session (with db) for my authentication.

right now i want to save a chosen language to a cookie and save that for a long time so they dont have to set their language every time.

$cookie = array('name' => 'language', 'value' => $this->input->post('language'), 'expire' => '31104000', //seconds, approx. one year

before this, my session (auth) always ended when i closed the window. that was good. but now when i set the cookie i looks like the cookie also saves my session for that time.

so when i close the window and come back to the web application, I'm still logged in. thats not the way it supposed to be.

How can i separate these two?

Thanks in advance!



CI doesn't have the option to terminate the session when you close the browser.

So the question is what did you modify to get that to work, and how does that interfere with setting a cookie manually...

:long: Obviously I'm very confused...

I think what you are looking for is:


default = 7200
options = None

The number of seconds you would like the session to last. The default value is 2 hours (7200 seconds). If you would like a non-expiring session set the value to zero: 0


Got this from the online user's guide: http://ellislab.com/codeigniter/user-gui...sions.html.

Why don't you just put both language and login in the (session) userdata? well...i just did. sorry guys, for this useless topic.

you may close the topic...

For furture reference- CI 2.0 does allow you to kill a session on broswer close - in 1.7.x you need to use a 3rd party extension or write your own.

In CI 2.0 config.php you'll find :
$config['sess_expire_on_close'] = [bool, TRUE or FALSE]

Pretty simple and a big reason to upgrade! Aside from all the other reasons! Wink

Nice! Thanks for the info. Can't wait for the stable version...

Also goodbye php4 :coolsmirk:

ps. CodeIgniter 2.0 - Now with more Awesome

[quote author="Bartolo!" date="1290533610"]Nice! Thanks for the info. Can't wait for the stable version...[/quote]

Honestly, 2.0 is stable. There are more 1.7.x fixes in 2.0 and I've not seen a problem yet. I admint, I'm only using 2.0 on 2 projects, but it's solid as far as the most common functionality is concerned.

And yes, much Awesome.

Theme © iAndrew 2016 - Forum software by © MyBB