Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Anyway, here's some code -
- IF ($this->form_validation->run()){ //<---Form validation.
- IF (!$this->User->login( //<---Attempt to log in the user with POST data
- addslashes(strtolower($this->input->post('username', TRUE))), //<-Username
- addslashes($this->input->post('password', TRUE)), //<- Password
- $this->getIP())){ //<-IP
- /*If the login failed stuff goes here bla bla not relevant.*/
- } ELSE {
- SWITCH($this->User->stale('Permissions')){ //<- This works
- CASE 'ADMIN':
- redirect('Admin');
- BREAK;
- /*Some other stuff but not relevant*/
- }
- }
- I've set a breakpoint in the Admin controller class constructor :
- CLASS Admin EXTENDS CI_Controller{
- public FUNCTION __construct(){
- PARENT::__construct(); //<-This gets hit.
- $this->load->model('User_Model', 'User'); //<- So does this, but when the $_SESSION value appears in the Variables view, it only has a single value in it.
- $this->User->ID = $this->session->UserID;
- /*Some other stuff that goes here; again, not relevant.*/
- }
- }
- Then there's also where the session data is being set; within the `User_Model` `Login( ... )` method -
- CLASS User_Model EXTENDS MY_Model{ //<----- MY_Model is just an extension of the CI_Model class that lets me use some of our Database stuff. Testing shows that it all checks out.
- public FUNCTION login($userName, $password, $IP){
- $row = $this->database->get_where('users', ARRAY('UserName' => $userName))->row_array()['UserName'];
- IF (!ISSET($row)){
- /*bla bla bad username handle it.*/
- } ELSE {
- /*Check password against username*/
- IF (/*Stuff*/) {
- /*Bla bla bad password handle it.*/
- } ELSEIF(/*check for already logged in*/){
- /*Bla bla logged in already handle it.*/
- } ELSE {
- /*Login was successful and there was much rejoicing (yaaay) handle it...*/
- /*Then I try and set the session values so that they are accessible after the redirect to the Admin controller:*/
- $this->session->UserID = $row['UserID'];
- /*and many others which aren't persisting*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement