0

Well, I am going straight, How can i store session into database? I have tried and stored session into database but It will delete automatically from db because of codeigniter database garbage collector.

I don't know how to keep all the sessions? I don't want to delete any session from database. I don't want to delete session until database user delete the row.

Moreover, I want to develop user can log out from all the sessions.

Please share your thoughts. thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Bhargav Dave
  • 109
  • 1
  • 8
  • Check please documentation - https://codeigniter.com/user_guide/libraries/sessions.html#session-drivers – Dmitry Leiko Dec 11 '19 at 15:00
  • Does this answer your question? [How do I save PHP session data to a database instead of in the file system?](https://stackoverflow.com/questions/36753513/how-do-i-save-php-session-data-to-a-database-instead-of-in-the-file-system) – niac Dec 11 '19 at 15:01

2 Answers2

1

Set the session expiration value of sess_expiration in the config to 0 if you don't want it to timeout unless the browser is closed, or set it to an crazy amount like 5 years.

sess_expiration: The number of seconds you would like the session to last. If you would like a non-expiring session (until browser is closed) set the value to zero: 0

The config file is found at: application/config/config.php

You can also disable automatic session regeneration by setting sess_time_to_update to 0.

Reference: https://codeigniter.com/user_guide/libraries/sessions.html#session-preferences

Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • I added this but session still removed from database. Moreover i have put 0 in sess_expiration also, but still its not working. – Bhargav Dave Dec 12 '19 at 13:19
0

Set the $config['sess_expiration'] = 0 for lifetime.

Piyush Shukla
  • 244
  • 1
  • 11
  • I added this but session still removed from database. Moreover i have put 0 in sess_expiration also, but still its not working. – Bhargav Dave Dec 12 '19 at 13:19