adding sessions

  • glennn
  • Born
  • Born
  • glennn
  • Posts: 1

Post 3+ Months Ago

i have a simple login script that uses cookies and i'd love to utilize sessions - could someone show me how to do this?

here's where the cookie is checked:
Code: [ Select ]


$username_from_cookie = $_COOKIE[$cookiename]; //retrieve contents of cookie

if($permission_level==''){

$sql="SELECT * FROM users WHERE username='$username_from_cookie'";

}else{

$threshold = $permission_level-1;

$sql="SELECT * FROM users WHERE username='$username_from_cookie' AND permissions>'$threshold'";

}

$result=mysql_query($sql);

// Mysql_num_row is counting table rows

$count=mysql_num_rows($result);

// If result matches $myusername and $mypassword, table row must be 1 row

if($count==0){

{

header("location:login.php");

}

}
  1. $username_from_cookie = $_COOKIE[$cookiename]; //retrieve contents of cookie
  2. if($permission_level==''){
  3. $sql="SELECT * FROM users WHERE username='$username_from_cookie'";
  4. }else{
  5. $threshold = $permission_level-1;
  6. $sql="SELECT * FROM users WHERE username='$username_from_cookie' AND permissions>'$threshold'";
  7. }
  8. $result=mysql_query($sql);
  9. // Mysql_num_row is counting table rows
  10. $count=mysql_num_rows($result);
  11. // If result matches $myusername and $mypassword, table row must be 1 row
  12. if($count==0){
  13. {
  14. header("location:login.php");
  15. }
  16. }


if someone could kindly show me how i'd start a session once a person logs in and then check his logged in status, i'd be forever grateful...

regards,
glennn

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 103 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.