Jump to content

session problems


TobesC

Recommended Posts

here is the authentication i use.

 

login script:

-user submits email and password

 

<?php

session_start();

if (!isset($_SESSION['tries'])) {

session_register($_SESSION['tries']);

$_SESSION['tries']=0;

}

mysql_connect;

mysql_select_db;

$email=trim(strip_tags($_POST['email']));

$password=trim(strip_tags($_POST['password']));

if ($email!="") {

$result=mysql_query("SELECT * FROM `users` WHERE `email`='$email'");

$row=mysql_fetch_array($result);

if ($password==$row['password']) {

session_register($_SESSION['uid']);

$_SESSION['uid']=$row['uid'];

session_register($_SESSION['email']);

$_SESSION['email']=$email;

session_register($_SESSION['session']);

$_SESSION['session']=session_id();

header ("location: ../index.php");

}

else {

$_SESSION['tries']=$_SESSION['tries']+1;

if ($_SESSION['tries']>2) {

header ("location: ../reset.php");

}

else {

header ("Location: ../index.php");

}

}

}

else {

header ("Location: ../index.php");

}

?>

 

authentication check (at beginning of each page of site):

 

session_start();

$now=session_id();

$session=$_SESSION['session'];

if ($now==$session) {

$logged="y";

}

if $logged equals y, other options are present.

 

any help would be greatly appreciated. this is driving me crazy.

Link to comment
https://forums.phpfreaks.com/topic/54369-session-problems/#findComment-268958
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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