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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.