Welcome Guest, Not a member yet? Register   Sign In
[Solved] Session issue : Can't keep it persistent

(This post was last modified: 12-22-2016, 01:19 AM by Jurden.)


I don't know why but I lose my session at any refresh.
I try to store it by file and now in my database.

Here it's the only thing I have when i refresh my page (anytime different) :
PHP Code:
   [__ci_last_regenerate] => 1481814234

This is my current config :

PHP Code:
$autoload['libraries'] = array( 'database''session' ); 

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 30000;
$config['sess_regenerate_destroy'] = TRUE;

$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';

$config['global_xss_filtering'] = TRUE

PHP Code:
public function createSession(){
       if( !isset( $this->session->watch_dog ) ){
       ifget_cookie('watch_dog') == null ){

   public function addConnectionCounterAttempt(){
       // SESSION
       $new_value $this->session->userdata['watch_dog'] + 1;
       $this->session->set_userdata'watch_dog'$new_value );
       // COOKIE
       set_cookie'watch_dog'$new_value'3600' );

If you have any ideas...
Thank you.

sess_save_path has to be the name of your sessions table if you're using the database driver.

I changed the path but still the same.
I try to use native sessions instead and same result.

(This post was last modified: 12-16-2016, 09:23 AM by skunkbad.)

Another thing is that null ever will be == null. Instead you would use:

PHP Code:
if( is_nullget_cookie('watch_dog') ) ) 
OR you could probably just do:
PHP Code:
if( get_cookie('watch_dog') ) 

Well noticed.
I'll keep looking on that issue.

I finaly found the solution.
I just reset my cookies configuration and it work again.

I have a problem like this.

Everytime when i refresh the page, it creates a new session. What should i do?

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'pbsession';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'pbsession';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;


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

I use PHP 7.1.2, IIS 7 and Codeigniter 3.1 on Windows Server 2008 R2.

(12-22-2016, 01:19 AM)Jurden Wrote: I finaly found the solution.
I just reset my cookies configuration and it work again.

What does that mean? How do you reset this? It would be nice if you could elaborate on this a bit more.

He put the cookie configuration back to it's default in the config.php file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Correct Wink

Theme © iAndrew 2016 - Forum software by © MyBB