简体   繁体   中英

Session destroyed after redirect in codeigniter 3

the issue i am facing is when i redirect to some page my session got destroyed. i am facing this issue in live server only and working flawlessly in localhost. this issue was not there few months ago on different hosting company

here is my session configuration

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

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

You are using the "files" driver so you must supply a path to $config['sess_save_path'] . You set the value to NULL which will not work.

The value assigned to $config['sess_save_path'] must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver .

For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this

$config['sess_save_path'] = dirname(FCPATH .'/sessions/'); 

The other thing to try is being explicit with the cookie_domain, ie.

$config['cookie_domain']    = '.yourdomain.tld';

Be sure to include the leading dot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM