Welcome Guest, Not a member yet? Register   Sign In
session and cookie question
#1

PHP Code:
    public function logout() {

        
$this->session->unset_userdata('logged_in');
        
$this->session->unset_userdata('user_id');
        
$this->session->unset_userdata('username');
        
$this->session->sess_destroy();

        
// Message
        
$this->session->set_flashdata('success''You are logged out!');

        
redirect('admin/users/login');
    } 


IS the above code - deletes and cookies? If put this >>> // inside logout() getting 500 ERROR AFTER LOGOUT, WHAT TO DO TO DELETE COOKIES???

PHP Code:
if ($this->input->get_cookie('user_id') !== NULL) {
$this->input->delete_cookie('user_id');
$this->input->delete_cookie('username');
$this->input->delete_cookie('logged_in');



// SET IN LOGIN SECTION AS

PHP Code:
// SET IN LOGIN SECTION AS 

if ($remember == 1) {
$cookie = array( 
'name'   => 'user_id'
'value'  => $user_id
'domain' => ''
'path'   => '/'
'prefix' => ''
'secure' => FALSE 
); 

// Set the cookie to confirmed 
$this->input->set_cookie($cookie); 

$cookie = array( 
'name'   => 'username'
'value'  => $username
'domain' => ''
'path'   => '/'
'prefix' => ''
'secure' => FALSE 
); 

// Set the cookie to confirmed 
$this->input->set_cookie($cookie); 

$cookie = array( 
'name'   => 'logged_in'
'value'  => 'true'
'domain' => ''
'path'   => '/'
'prefix' => ''
'secure' => FALSE 
); 

// Set the cookie to confirmed 
$this->input->set_cookie($cookie); 
Reply
#2

Try to switch on logging and see if a specific error is logged.

Tho in your code, the one thing I would check is session destroy method. You are destroying the session, then adding flash-data to session, there might be some conflict with that - you might have to recreate session before you can call set_flashdata.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB