![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
Sessions
Ok I have created this session script. I think i am missing something but im not really sure what it is and im wondering if someone can tell me i am or not.
[php] <?php ######################################## ######################################## ## session.php ## ## ## ## ######################################## ######################################## ######################################## ##Required Files ######################################## require("config.php"); require("constants.php"); ######################################## ##Start Sessions ######################################## class Session{ //Values Of $_SESSION //example: $_SESSION['username']; public $sess_user = "username"; public $sess_email = "email_address"; public $sess_ip = "ip"; //Value Of $_COOKIE //example: $_COOKIE['username']; public $cook_user = "username"; public $cook_pass = "password"; //Value Of $_POST //example: $_POST = $_COOKIE public $post_user = "username"; public $post_pass = "password"; //Misc Vars public $profile = "profile"; //Verify that the user got a session function verifySession(){ $this->sess_user = sess_user; $this->sess_email = sess_email; $this->sess_ip = sess_ip; if(!isset($_SESSION[$this->sess_user]) || !isset($_SESSION[$this->sess_email]) || !isset($_SESSION[$this->sess_ip]) || $_SESSION[$this->sess_ip] != $_SERVER['REMOTE_ADDR']){ return false; }else{ return true; } } //Verify that cookie exist function verifyCookie(){ $this->cook_user = cook_user; $this->cook_pass = cook_pass; if(isset($_COOKIE[$this->cook_user]) && isset($_COOKIE[$this->cook_pass])){ return true; }else{ return false; } } //Create Session function createSession(){ $this->username = $_SESSION[$this->sess_user]; $this->email = $_SESSION[$this->sess_email]; $this->ip_addy = $_SESSION[$this->sess_ip]; session_start(); } //Make Cookie mmm cookies ![]() function writeCookie() { setcookie($this->cookie_username,$this->username); setcookie($this->cookie_password,$this->password); } //Verify That The User Has Enter In Login Info Correctly function verifyLogin(){ $this->post_user = post_user; $this->post_pass = post_pass; if(!isset($_POST[$this->post_user]) || !isset($_POST[$this->post_pass]) && $_POST[$this->post_user] != '' && $_POST[$this->post_pass] != ''){ return true; }else{ return false; } } //Create Login function createLogin(){ $this->post_username = $_POST[$this->post_username]; $this->post_password = md5($_POST[$this->post_password]); } //If User Successfully Logged In Redirect To Profile function login(){ $this->profile = profile; $vfy_session = $this->verifySession(); if($vfy_session){ $this->redirect($this->profile); } $vfy_cookie = $this->verifyCookie(); if($vfy_cookie){ if($db->MySQL){ $this->createSession(); $this->redirect($this->profile); } } $vfy_form = $this->verifyLogin(); if(!$vfy_form){ if($db->MySQL){ return $this->error; }else{ $this->createSession(); } if($_POST[$this->post_cookie]){ $this->writeCookie(); } $this->redirect($this->profile); } } //If User Hits Logout Then We Redirect //That User Back To The Login Page Again ![]() //And We Destroy The Session function logout(){ $_SESSION = array(); session_destroy(); header("Location: " . $this->loginPage); } function loggedIn(){ //Check To See If User Is Logged In $vfy_session = $this->verifySession(); $vfy_cookie = $this->verifyCookie(); if($vfy_cookie){ if($db->MySQL){ $this->createSession(); }else{ $this->redirect($this->profile); } } } }; $session = new Session; ?> [/php] |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
your request is incredibly vague. How about testing your own script and when you cant figure out a specific part then maybe post for help on it
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi freelance scripts - http://ryanguthrie.com/index.html |
|
|
|
|
|
#3 |
|
Programmer
|
Like I am wondering if that is a suffient(sp?) session file or do you think i need to add more or what in overall/
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
This isn't meant to be rude, but informative. Not many people are going to look at your code in detail merely to grade it for completeness or style. Most people will chip in to help find a problem, provided that you give a clear description and clean code. That localizes the problem and reduces the time investment, as well as offering some challenge.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|