Welcome Guest, Not a member yet? Register   Sign In
Store session in db or in file
#1

hi , where is the best practice store session in file or in db ?
How many time delete file or record in db ? do it automatically with a cronjob ?
Reply
#2

i prefere session file
Enlightenment  Is  Freedom
Reply
#3

(07-28-2021, 12:33 PM)pippuccio76 Wrote: hi , where is the best practice store session in file or in db ?
How many time delete file or record in db ? do it automatically with a cronjob ?

Read this tip from the user guide -> https://codeigniter.com/user_guide/libra...#bonus-tip
Reply
#4

It depends on your use case. I have an application hosted on 2 web servers behind a load balancer. They both connect to the same database. So I set the session in the database. That way it doesn't start 2 separate session on each server.

If you need to read all the active sessions of your users, it's easier with a database.

Depending on the amount of data saved in the session and the quantity of users, it may be faster or slower with on method or the other. Try them all and see what best fit your use case.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

(This post was last modified: 08-01-2021, 11:06 AM by pippuccio76.)

(07-29-2021, 04:22 PM)includebeer Wrote: It depends on your use case. I have an application hosted on 2 web servers behind a load balancer. They both connect to the same database. So I set the session in the database. That way it doesn't start 2 separate session on each server.

If you need to read all the active sessions of your users, it's easier with a database.

Depending on the amount of data saved in the session and the quantity of users, it may be faster or slower with on method or the other. Try them all and see what best fit your use case.

hi , i see that the env sample file are changed , there is a documentation for every line of env file ? Do you delete session file or session db programmatically?
Reply
#6

(08-01-2021, 11:04 AM)pippuccio76 Wrote: Do you delete session file or session db programmatically?

No. The framework takes care of that.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#7

Just wand to add Redis as a possible storage for sessions. We run in an AWS environment with Fargate and ECS workers and an ElastiCache cluster handling the sessions.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB