I have dug through all the codeigniter session topics, but have not found any solutions.
I have setup a Login Controller for my project that sends the username and password onto my Login Model. This all works fine. Once I pull the information out of the database, I am setting some session information.
Here are some code snippets: Config:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 14400;
$config['sess_save_path'] = '/var/www/mysite.com/application/cache/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;
Autoload:
$autoload['libraries'] = array('session', 'database', 'form_validation', 'email');
Pulling an idea from the database (works fine):
$UserID = $this->LoginModel->login($username, $pass);
Setting a session variable:
$this->session->set_userdata('Sess_ID', md5($UserID.date('YmdHis')));
After the process is complete, the user is sent to the next page. This is where the problems are. I load a simple check for the session variables and even a var_dump, but every time the session is empty.
public function __construct() {
parent::__construct();
echo var_dump($this->session);
if ($this->SessionModel->basic() == false) {
//$this->SessionModel->logout();
echo 'Session Error';
}
}
So, the question is, how can I call the session from the next page/controller? I am used to using the session_start(), but that isn't needed in codeigniter. I have also confirmed that session files can and are being written to the directory.
Input please...
to get all session data use:
print_r($this->session->all_userdata());
for specific data:
print_r($this->session->userdata('name_of_the_session_variable');
in your case:
print_r($this->session->userdata('Sess_ID'));
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.