$lifetime and autologin

Help
2004-01-08
2013-04-09
  • Sergei Klitchko

    Sergei Klitchko - 2004-01-08

    I want a autologin for users on my site after close and open them browsers and change a $lifetime in my class Example_Session and class Example_Auth on 10080 (week in minutes). But then my login and registration not work. Errors not displays. Simple not work. Change back on 0 and 15 - all work.
    It is correctly change $lifetime for autologin? Thanks.

     
    • Layne Weathers

      Layne Weathers - 2004-01-08

      If I understand you correctly, you want your users' login to last for a week, regardless of the session. PHPLib works using session cookies - you close the browser, you lose the session.

      You will need to set a persistent cookie with the user's user_id, setting the lifetime to one week. Then, you will need to create the function auth_preauth() inside your Example_Auth class - this function should check for the persistent cookie and return the user_id if it exists or false if it does not.

      I trust you have already considered and accepted the security risks inherent in this implementation.

       
    • Sergei Klitchko

      Sergei Klitchko - 2004-10-04

      Problem: Autologin users don't get registered vars. Why? Thanks.

      My auth_preauth:

      function auth_preauth()
      {
          $uid = false;
          if ($_COOKIE["he"]!=="")
              {
                  $this->db->query(sprintf("select username, perms from %s where user_id = '%s' ",
                      $this->database_table,$_COOKIE["he"]));
                  while($this->db->next_record())
                  {
                      $this->auth["uname"] = $this->db->f("username");
                      $this->auth["perm"] = $this->db->f("perms");
                  }
                  $uid = $_COOKIE["he"];
              }
          return $uid;
      }

      Autologin $_SESSION:

      Array ( [auth] => example_default_auth Object ( [classname] => Example_Default_Auth [persistent_slots] => Array ( [0] => auth ) [lifetime] => 0 [refresh] => 0 [mode] => log [magic] => [nobody] => 1 [cancel_login] => cancel_login [auth] => Array ( [uid] => a020f558433a0186e0ba811424fa61b7 [perm] => user [exp] => 1096899754 [uname] => 2222 [refresh] => 1096899740 ) [in] => 1 [db] => db_example Object ( [Host] => localhost [Database] => test [User] => kk [Password] => [Auto_Free] => 0 [Debug] => 0 [Halt_On_Error] => yes [PConnect] => 0 [Seq_Table] => db_sequence [Record] => Array ( ) [Row] => [Errno] => 0 [Error] => [type] => mysql [revision] => 1.2 [Link_ID] => 0 [Query_ID] => 0 [locked] => ) [database_class] => DB_Example [database_table] => auth_user ) )

      Not Autologin $_SESSION (normal):

      Array ( [auth] => example_default_auth Object ( [classname] => Example_Default_Auth [persistent_slots] => Array ( [0] => auth ) [lifetime] => 0 [refresh] => 0 [mode] => log [magic] => [nobody] => 1 [cancel_login] => cancel_login [auth] => Array ( [uid] => a020f558433a0186e0ba811424fa61b7 [perm] => user [exp] => 1096897065 [refresh] => 1096895847 [uname] => 2222 ) [in] => 1 [db] => db_example Object ( [Host] => localhost [Database] => test [User] => kk [Password] => [Auto_Free] => 0 [Debug] => 0 [Halt_On_Error] => yes [PConnect] => 0 [Seq_Table] => db_sequence [Record] => Array ( ) [Row] => [Errno] => 0 [Error] => [type] => mysql [revision] => 1.2 [Link_ID] => 0 [Query_ID] => 0 [locked] => ) [database_class] => DB_Example [database_table] => auth_user ) [lang] => ru [block] => forum )

       

Log in to post a comment.