I am trying to use session in codeigniter. What I have done:
if ( verifyHashedPassword($this->input->post('teacher_password'),$result['teacher_password']))
{
$this->session->set_userdata('teacher_email',$this->input->post('teacher_email'));
$responseArray['success'] = true;
}
I am trying to fetch using:
if ( $this->session->userdata('teacher_email') )
{
echo "session is set.";
}
else
{
echo "session is not set.";
}
after redirection to this page. I am getting alwasy session is not set. Why it is so?
session and cookie configuration is:
$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;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists.
| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;