CodeIgniter Forums
Why am I logged out after a short period? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Why am I logged out after a short period? (/thread-73949.html)



Why am I logged out after a short period? - ratmil - 06-26-2019

Hi, I have a site developed using CodeIgniter and I recently moved everything to a new server. But I am having some problems in the new server.  After logging in with user (admin) I get redirected to login form.
PHP settings seems to be OK.
session.gc_maxlifetime = 1440
session.cache_expire = 180
session.cookie_lifetime = 0


RE: Why am I logged out after a short period? - InsiteFX - 06-27-2019

And what are your CodeIgniter config values set to?

Is the session file or database?


RE: Why am I logged out after a short period? - ratmil - 06-27-2019

Hi, thanks for answering.
I am new to CodeIgniter. We just copied the site to a new server, but we didn't write the code. The funny thing is everything worked fine in the old server and it also works in my local PC. We didn't change much.

These are session related settings:

PHP Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] =  'sess';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE

Cookie settings:

PHP Code:
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE



RE: Why am I logged out after a short period? - ratmil - 06-27-2019

Solved setting session driver to database.
Thanks.


RE: Why am I logged out after a short period? - InsiteFX - 06-27-2019

If you put it on a new sever then you need to change the base url in the ./application/config/config.php file.

See it to your new server url.


RE: Why am I logged out after a short period? - ratmil - 06-27-2019

That was already done.
However, after setting session driver to database site is slower.


RE: Why am I logged out after a short period? - InsiteFX - 06-27-2019

you can try setting the cookie_path to .your_domain.com


RE: Why am I logged out after a short period? - wapshekhar - 06-28-2019

(06-26-2019, 07:31 PM)ratmil Wrote: Hi, I have a site developed using CodeIgniter and I recently moved everything to a new server. But I am having some problems in the new server.  After logging in with user (admin) I get redirected to login form.
PHP settings seems to be OK.
session.gc_maxlifetime = 1440
session.cache_expire = 180
session.cookie_lifetime = 0

Code:
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = TRUE;

i have same situation some month ago using this config solved for me..



RE: Why am I logged out after a short period? - dave friend - 06-28-2019

(06-28-2019, 02:03 AM)wapshekhar Wrote:
(06-26-2019, 07:31 PM)ratmil Wrote: Hi, I have a site developed using CodeIgniter and I recently moved everything to a new server. But I am having some problems in the new server.  After logging in with user (admin) I get redirected to login form.
PHP settings seems to be OK.
session.gc_maxlifetime = 1440
session.cache_expire = 180
session.cookie_lifetime = 0

Code:
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = TRUE;

i have same situation some month ago using this config solved for me..

When using the 'files' driver the value for $config['sess_save_path'] must be an absolute path to the folder, e.g.

PHP Code:
$config['sess_save_path'] = "/var/www/project/sessions"

Read and write permissions must be set so that the webserver can use the folder.