Welcome Guest, Not a member yet? Register   Sign In
CI 2.0: sessions
#1

[eluser]diostm[/eluser]
Hello!

I was creating my own authorization Model, and I needed to use sessions to store user data in it.

I was a little bit surprised, because CI don't use PHP native sessions, but it uses cookies.

But there is one thing that disturbs me: "Session" don't expire when browser is closed. Temporary solution is to set "sessions" expire time to 5 minutes and update it when it is necessary(less then a minute for example). But I find this decision not sexy. Update on every step is too not very sexy decision too.

Flashdata using is not the right solution too, because when I open my web browser and go to the web page, which updates flashdata (using $this->session->keep_flashdata('item')).

The main problem of my temporary decision is that I was forced(may be I'm wrong?) to use global preferences to set "sessions" expire time to 5 minutes in application/comfigs/config.php. The problem is that my application need cookies for other goals and I have to use cookie helpers functions to use this features.

And also there may be other problems with it... Is there any possibilities to set a local configs(just for this model for example)?
#2

[eluser]treeface[/eluser]
Hey diostm,

As far as I know, CI sessions do not have this feature built in, but you might want to give this thread a look:

http://ellislab.com/forums/viewthread/70036/
#3

[eluser]WanWizard[/eluser]
Maybe a tip for next time: search the forum before asking questions, and read up on what's been said here.

First of all, CI only uses cookies if you tell it to. It is configured so by default, as when you install CI, there is no database. But it is absolutely perferred to use the database for sessions. If you do, CI will only send a cookie to the client comtaining the session id, just like PHP sessions do.

And indeed, the standard CI code doesn't allow you to specify 0 as session expiry time, if you do, it will assume you forgot to configure it and use 2 years as expiry time. Not handy, I agree. The fix is very simple, and discussed here about a million times already...




Theme © iAndrew 2016 - Forum software by © MyBB