Re: [Phplib-users] Basic authentication (fwd)
Brought to you by:
nhruby,
richardarcher
From: Tarique S. <ta...@sa...> - 2002-02-03 05:10:15
|
-- ========================================================== PHP Applications for E-Biz : http://www.sanisoft.com The Ultimate Ghazal Lexicon: http://www.aaina-e-ghazal.com ========================================================== ---------- Forwarded message ---------- Date: Sun, 3 Feb 2002 10:22:20 +0530 (IST) From: "Tarique Sani <ta...@sa...>" <ro...@bo...> To: Carl Youngblood <ca...@yo...> Cc: "Phplib (E-mail)" <Php...@li...> Subject: Re: [Phplib-users] Basic authentication On Sat, 2 Feb 2002, Carl Youngblood wrote: > Yeah, I would like some code samples if you don't mind. I added code to my > auth_validatelogin() function to set the cookie with the userid in it, but Here are the relevant code snippets, note that you will have to implement "Forget Me" functionality separately ================================ function auth_preauth(){ global $uidcookie; $uid= false; $this->db->query(sprintf("select * from %s where uid = '%s' ", $this->database_table, $uidcookie)); while($this->db->next_record()) { $uid = $this->db->f("uid"); $this->auth["uname"]=$this->db->f("username"); $this->auth["email"]=$this->db->f("email"); $this->auth["name"]=$this->db->f("name"); $this->auth["perm"] = $this->db->f("perms"); $this->auth["classid"]=$this->db->f("classid"); } return $uid; } function auth_validatelogin(){ global $username, $password, $remind_me; if(isset($username)) { $this->auth["uname"]=$username; ## This provides access for "loginform.ihtml" } $uid = false; $this->db->query(sprintf("select * from %s where username = '%s' and password = '%s'", $this->database_table, addslashes($username), addslashes($password))); while($this->db->next_record()) { $uid = $this->db->f("uid"); $this->auth["uname"]=$this->db->f("username"); $this->auth["email"]=$this->db->f("email"); $this->auth["name"]=$this->db->f("name"); $this->auth["perm"] = $this->db->f("perms"); $this->auth["classid"]=$this->db->f("classid"); if (isset($remind_me)){ $this->auth["remind_me"]="yes"; setCookie("uidcookie",$uid,time()+31536000); } } return $uid; } } ========================== -- ========================================================== PHP Applications for E-Biz : http://www.sanisoft.com The Ultimate Ghazal Lexicon: http://www.aaina-e-ghazal.com ========================================================== |