Welcome Guest, Not a member yet? Register   Sign In
Why call session not working?
#1

my config is like this :
Code:
$config['sess_driver'] = 'database';  // select database driver
$config['sess_save_path'] = 'ci_sessions';  // name of the mysql table
$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update']  = 300;

My autoload is like this :
Code:
$autoload['libraries'] = array('database', 'session', 'form_validation', 'functions');

In controller [font=Arial,]login.php :[/font]
Code:
$this->session->set_userdata('club', 'chelsea');

In controller [font=Arial,]dashboard.php :[/font]
Code:
echo $this->session->userdata('club');

It did not succeed in calling the session club if a different controller
But, when I call session club in the same controller(controller [font=Arial,]login.php), it's working[/font]
I try 
Code:
$this->library->load('session');

 in the constructor of 

Code:
Dashboard.php

. But it's not a success

Any solution to solve my problem?
Thank you
Reply
#2

(This post was last modified: 12-05-2018, 10:41 AM by php_rocs.)

@garimapatil


Instead of this...
PHP Code:
echo $this->session->userdata('club');// [Technically this should work.] 

Try this...
PHP Code:
echo $this->session->club


Documentation: https://codeigniter.com/user_guide/libra...ssion-data

Are you using any debugging tools?

Also, keep in mind that the login page must be executed first in order for the session variable to be set.  If the dashboard page is executed first then the session variable will not exist.
Reply
#3

(12-05-2018, 10:40 AM)php_rocs Wrote: Try this...
PHP Code:
echo $this->session->club

Based on the config items I think the OP is using a CI version < 3.0 and so your suggestion of $this->session->club; won't work.
Reply
#4

(This post was last modified: 12-06-2018, 11:01 AM by php_rocs.)

@garimapatil,

What version of CI are you using?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB