Welcome Guest, Not a member yet? Register   Sign In
Session variable related issue
#6

[eluser]boltsabre[/eluser]
Hmmm, sorry we couldn't help.

To the best of my knowledge, when a user clicks on the 'back' button either on the screen, or if they have a fancy mouse with a back button and they press it, the page will reload - it does not pull the page from a cache, but will actually pull the file from the server again, thus running all js and php (or whatever) scripts again.

So... if, and correct me if I'm wrong, in your situation you want to check if a user is logged in, even if they click the back button, after they have logged out. Well, any page that can only be accessed whilst logged in should check for a 'logged in' session variable. Best to put it in a helper, and just call it in every controller function that requires it (place it up the top, it should run before any other of that controllers code to prevent issues). It would look something like this:

Code:
// this is your helper function
public function checkLoggedInStatus(){
   if(!isset($this->session->userdata('userId'))){
      // session variable NOT set, user is NOT logged in.
      redirect ('myUserController/login');
   }
}

// and just call it in your controllers like this
public function thisIsAControllerYouMustBeLoggedInToView(){
  // load your helper (well duh)
   $this->load->helper('loggedInHelper');
   $check = checkLoggedInStatus();
   // if user not logged in helper function redirects them to myUserController/login, else
   // continue with this controller and its intended purpose

   // rest of controller code here

And that's it... if a user isn't logged in they get redirected to the login page. Please let us know if that does/does not fix your problem.


Messages In This Thread
Session variable related issue - by El Forum - 07-07-2011, 10:25 PM
Session variable related issue - by El Forum - 07-07-2011, 11:59 PM
Session variable related issue - by El Forum - 07-08-2011, 02:58 AM
Session variable related issue - by El Forum - 07-08-2011, 06:59 AM
Session variable related issue - by El Forum - 07-08-2011, 07:50 AM
Session variable related issue - by El Forum - 07-08-2011, 08:15 AM
Session variable related issue - by El Forum - 07-08-2011, 10:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB