Welcome Guest, Not a member yet? Register   Sign In
How can we improve CI 3 sessions?
#1

Hi guys.

How can we improve CI sessions. When we put it on the live server it only works with setting the path to a specific directory:

sess_save_path = APPPATH . "/someDirectory"

However, this fills the directory with hundreds of sessions files? Let's say we don't want to store them in a database either.

What can we do to overcome this limitation?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#2

The session data does have to be stored somewhere? Where else could it be stored if not in the file directory or the database? You cannot store it in a cookie - are there any other options?
Reply
#3

I have no idea, I guess it doesn't take up too much space being a very small file size.

The only other thing I could think of was running a cron job periodically during the night to purge the session folder, but what is night time for anybody in the world. It's different?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#4

(02-12-2017, 09:52 AM)iamthwee Wrote: I have no idea, I guess it doesn't take up too much space being a very small file size.

The only other thing I could think of was running a cron job periodically during the night to purge the session folder, but what is night time for anybody in the world. It's different?

Sessions already have their own garbage collection, AKA "gc". Yes, you can do your own garbage collection, but you would ideally be using database sessions, because that allows you to purge by datetime.
Reply
#5

I believe CI cleans this out automatically. If you set sess_regenerate_destroy to TRUE, then old session data will be removed when it is regenerated.

I must admit I was suprised by how much session data was generated even in a table, but to be honest, I am not sure I know enough about sessions to worry about it. Just one of those things I have to let CI take care of. Perhaps if I had time I could do some experimenting with it, but the session table never gets too large to worry about. And it does seem to clean itself out because it never seems to be filled with old data.

For instance, on a site I am building at the moment that only myself and one other person has access too during build, the oldest session record is from the 7th Feb, although have been building the site for much longer than that. So the garbage collector must be doing it's job. (There are 46 entries though, which is the bit that confuses me. But not enough to look into it in any detail.)

Best wishes,

Paul.
Reply
#6

Quote:If you set sess_regenerate_destroy to TRUE

OMG I can't believe I missed that! Well that solves it.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#7

I have experienced some problems with sess_regenerate_destroy. Don't assume that is your best option.
Reply
#8

Such as?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB