CodeIgniter Forums
cookie/session expiration time - 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: cookie/session expiration time (/showthread.php?tid=36124)



cookie/session expiration time - El Forum - 11-22-2010

[eluser]Bartolo![/eluser]
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.

Code:
$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!

regards,

Bartolo


cookie/session expiration time - El Forum - 11-22-2010

[eluser]WanWizard[/eluser]
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...


cookie/session expiration time - El Forum - 11-22-2010

[eluser]Bartolo![/eluser]
:long: Obviously I'm very confused...


cookie/session expiration time - El Forum - 11-22-2010

[eluser]BigDon[/eluser]
I think what you are looking for is:

Code:
sess_expiration

default = 7200
options = None

Description:
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-guide/libraries/sessions.html.


cookie/session expiration time - El Forum - 11-23-2010

[eluser]Bartolo![/eluser]
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...


cookie/session expiration time - El Forum - 11-23-2010

[eluser]Narkboy[/eluser]
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 :
Code:
$config['sess_expire_on_close'] = [bool, TRUE or FALSE]

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


cookie/session expiration time - El Forum - 11-23-2010

[eluser]Bartolo![/eluser]
Nice! Thanks for the info. Can't wait for the stable version...

Also goodbye php4 :coolsmirk:

ps. CodeIgniter 2.0 - Now with more Awesome


cookie/session expiration time - El Forum - 11-23-2010

[eluser]Narkboy[/eluser]
[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.