Why do i have to log in twice, when using PHP and Sessions?

Nick

New member
I am currently making a log in system for a friend. It is set up so that if someone without a login trys to view a private page they will be redirected away from it, This is done by checking if the $_SESSION['user'] is set. The first time someone log's in they get treated as if they are not logged in a they get redirected, however if they log in again straight afterward's it works as intended. If they anyway of solving this without making another page that sends the information twice before redirecting.

All help greatly appreciated
I am currently making a log in system for a friend. It is set up so that if someone without a login trys to view a private page they will be redirected away from it, This is done by checking if the $_SESSION['user'] is set. The first time someone log's in they get treated as if they are not logged in a they get redirected, however if they log in again straight afterward's it works as intended. If they anyway of solving this without making another page that sends the information twice before redirecting.
This happens in all browsers.
the code is:
if($pword==$rs['pword'])
{
session_start();
$_SESSION['user'] = $uname;
}
on the next page the code is:
<?php
session_start();
if(!isset($_SESSION['user']))
{
header("location:./index.php");
}
?>
sorry for putting everything twice
 
Back
Top