Jump to content

Help with a log in script (Already complete and working)


DiscoTrio

Recommended Posts

I have a code from my friend that was written about two years back and there is one part I need help with:  Somehow it remebers what page you came from and you stay on that page after you log in.  I need help changing that to a certain page.  Keep in mind the browser never goes to these log in scripts.

 

This is the part of the session controll script that logs you in and somehow marks what page you came from:

   function startSession(){
      global $database;
      session_start();

      $this->logged_in = $this->checkLogin();
      if(!$this->logged_in){
         $this->username = $_SESSION['username'] = GUEST_NAME;
         $this->userlevel = GUEST_LEVEL;
         $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      }

      else{
         $database->addActiveUser($this->username, $this->time);
      }
      $database->removeInactiveUsers();
      $database->removeInactiveGuests();

      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      }else{
         $this->referrer = "/";
      }

      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
   }

 

This finishes up your log in in another script:

   function procLogin(){
      global $session, $form;
      /* Login attempt */
      $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
      if($retval){
         header("Location: ".$session->referrer);
      }
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $form->getErrorArray();
         header("Location: ".$session->referrer);
      }
   }

 

In the first script I think (Not sure) these lines find out where your from and makes a value:

 

      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      }else{
         $this->referrer = "/";
      }

 

And this probably has somthing to do with making you go there...  I am not familiar with ever using the header function...

header("Location: ".$session->referrer);

 

 

If I can I want to specify what page you go to after logging in...

 

Thanx!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.