Welcome Guest, Not a member yet? Register   Sign In
Session in database, avoid multiple queries
#1

[eluser]jahsen[/eluser]
Hello,
I have setup codigniter sessions to use database, but this generates many sql queries..
Is it possible to avoid this situation somehow.. for example custom session class and hooks or something?
Thank you.
#2

[eluser]Sudz[/eluser]
Hi,

What does it mean "generates many sql queries"?

The Session class has built-in garbage collection which clears out expired sessions so you do not need to worry about it.
#3

[eluser]rana[/eluser]
If you are thinking this session operations making your application perform slower, I guess you are wrong. You shouldn't be worrying about this that much, its already been developed/optimized by many developers like you/me (power of open source Smile ), so keep faith on it and concentrate on other parts of your application.
#4

[eluser]TheFuzzy0ne[/eluser]
The session data is pulled once for each request, and updated each time you call $this->session->set_userdata().

There are two solutions I know of to get around this:
1) Make sure you update all of your userdata in one go.
2) Create a post controller hook that will update your session once your controller has finished executing. The only problem here is that occasionally, you will echo out some data and exit immediately, which will mean your hook won't ever get called.




Theme © iAndrew 2016 - Forum software by © MyBB