CodeIgniter Forums

Full Version: PHP - Session problem in codeigniter framework
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I have a website which has started causing a strange problem from last few days. 
It has login protected area. On live server, when I try to login, it fails to create session. and redirects me to home page again. While the same login work on local machine perfectly.

Actually what I think, problem is this that session is created but it gets lost when I redirect user to other page.
It was working fine few days ago but suddenly it has started causing this frustrating problem.

I am using codeigniter framework. Can any one help please ?

Thanks
How do you load the "session" library?
What are the session config settings you are using?
(10-12-2017, 10:18 AM)dave friend Wrote: [ -> ]How do you load the "session" library?
What are the session config settings you are using?

Im Loading Session Library in autoload file.
$autoload['libraries'] = array('database', 'session', 'form_validation');

Session Config Settings:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'pop_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;
Mostly it is your session_save_path, the documentation shows how
to set it up for files.
(10-13-2017, 03:08 AM)InsiteFX Wrote: [ -> ]Mostly it is your session_save_path, the documentation shows how
to set it up for files.

Still No Use im using codeigniter 3.0 and in my server PHP Version 7.1.7
create a session_save_path and assign it to $config['sess_save_path'] = 'your session's folder path';
Make sure your session's folder is writable.
(10-13-2017, 06:23 AM)Khadeer Wrote: [ -> ]
(10-13-2017, 03:08 AM)InsiteFX Wrote: [ -> ]Mostly it is your session_save_path, the documentation shows how
to set it up for files.

Still No Use im using codeigniter 3.0 and in my server PHP Version 7.1.7

create a directory and assigned it to $config['sess_save_path'] = 'your directory path';
Make sure the directory is writable
Have you followed all these details:

https://www.codeigniter.com/user_guide/l...les-driver

The path needs to be an absolute path. The permissions need to be high enough for access, 0700 is recommended, but there is also a note in the instructions about www-data access.

Quote:It was working fine few days ago but suddenly it has started causing this frustrating problem.

I would write a test page that did not redirect on session fail. Then at least you can use the profiler to look at what is in the session variables. Compare it to the page where you say the session is set. There might also be a problem in the code you are using to test the session status.

You originally quoted
PHP Code:
$config['sess_save_path'] = NULL
Which could not have ever worked.

Also it is worth upgrading your system files to 3.1.6, there have been many bug fixes and improvements since 3.0, you are about 12 versions behind, including fixes for sessions, although I do not really think your issue is caused by any of these, it might be.

If you are using an auth library of any description, perhaps there are some settings you have not updated in the auth package.

Hope something here helps,

Paul.
(10-13-2017, 06:23 AM)Khadeer Wrote: [ -> ]Still No Use im using codeigniter 3.0 and in my server PHP Version 7.1.7

PHP 7.1.0 was released on December 1st, 2016.
CI 3.0.6 (the last 3.0 one) was released on March 21st, 2016.

See the problem here?
Thanks Guys it is working now. I have upgraded my CI to Latest Version. Thanks a lot for your replies.