Session problem |
[eluser]Googlesg[/eluser]
Hi I am using your library. sometimes it return FALSE even logged-in. Can you please help me? Thanks /* the code */ $user_is_student = $this->session->auth('user_student'); if (!$user_is_student) { show_error("No Access."); } |-------------------------------------------------------------------------- | Session Variables |-------------------------------------------------------------------------- | | 'session_cookie_name' = the name you want for the cookie | 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie | 'session_expiration' = the number of SECONDS you want the session to last. | by default sessions last 7200 seconds (two hours). Set to zero for no expiration. | 'time_to_update' = how many seconds between CI refreshing Session Information | */ $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 86400; $config['sess_encrypt_cookie'] = TRUE; $config['sess_use_database'] = TRUE; $config['sess_table_name'] = 'ci_sessions'; $config['sess_match_ip'] = FALSE; $config['sess_match_useragent'] = TRUE; $config['sess_time_to_update'] = 300; /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | If you use the Encryption class or the Sessions class with encryption | enabled you MUST set an encryption key. See the user guide for info. | */ $config['encryption_key'] = "5a6WP41EvwqhB2e0TiQsaardG92fbMbX"; /* |-------------------------------------------------------------------------- | Cookie Related Variables |-------------------------------------------------------------------------- | | 'cookie_prefix' = Set a 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 | */ $config['cookie_prefix'] = ""; $config['cookie_domain'] = ""; $config['cookie_path'] = "/"; /* auth.php */ $user_table = "auth"; $session_auth = "logged_in"; $user_name = "username"; $password = "password"; $privilege = array('user_admin', 'user_teacher', 'user_student');
[eluser]WanWizard[/eluser]
What is 'auth'? The CI session library doesn't have an auth() method... And please your [ code ] (remove the spaces) tags around your code, it's not very readable this way.
[eluser]Googlesg[/eluser]
Thanks for your reply. auth function is inside MY_Session.php file. function auth($access) { if ($this->CI->config->item('sess_encrypt_cookie') == TRUE AND $this->CI->config->item('sess_use_database') == TRUE AND $this->CI->config->item('sess_table_name') != '') { include(APPPATH.'config/auth'.EXT); $authorized = $this->userdata($session_auth); if ($authorized) { if ($this->userdata($access) == TRUE) { return TRUE; } else { return FALSE; } } } else { show_error('ENCRYPTION AND DATABASE MUST BE ENABLED - PLEASE READ /APPLICATION/CONFIG/AUTH.PHP'); return FALSE; } }
[eluser]Googlesg[/eluser]
The post is regarding the SEAuth Library from http://ellislab.com/forums/viewthread/91741/ |
Welcome Guest, Not a member yet? Register Sign In |