Connecting Tech Pros Worldwide Forums | Help | Site Map

Sessions / PHP 4.3.1

NorwichLad
Guest
 
Posts: n/a
#1: Jul 17 '05

I have a website, to which members must "log on" to gain access.

The sequence of pages is as follows:

1. index.php
Contains form for username/password

2. login.php
starts session
<?
session_start();
session_register("user_id");
session_register("logged_in");
?>
validates authentication
A - if "ok"
i. sets $user_id and $logged_id
ii. goes to membersArea_frameset.php
B - if fails - goes to an error page

This setup normally works fine, for 99% of visitors.

However, every day i get a few emails from people who receive an error
message saying that the session has expired, rather than a successful login.
Each page (including the above frameset page) has an include of
'session_check.php'.

The contents of the file is:

<?
if ($logged_in != session_id())
{
echo "<script>self.location='error.php?error=2'</script>";
exit();
}
?>

For nearly all visitors, the above setup works fine.

Any ideas why some people are told straight after successfully logging in
that their session has expired? This is really worrying. I can't figure it
out.

Have I not set up the sessions correctly?

PHP - Version: 4.3.1



Andy Fish
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Sessions / PHP 4.3.1


maybe their browsers do not accept cookies?


"NorwichLad" <see-signature@hill.org.uk> wrote in message
news:brdj79$28ach$1@ID-176991.news.uni-berlin.de...[color=blue]
>
> I have a website, to which members must "log on" to gain access.
>
> The sequence of pages is as follows:
>
> 1. index.php
> Contains form for username/password
>
> 2. login.php
> starts session
> <?
> session_start();
> session_register("user_id");
> session_register("logged_in");
> ?>
> validates authentication
> A - if "ok"
> i. sets $user_id and $logged_id
> ii. goes to membersArea_frameset.php
> B - if fails - goes to an error page
>
> This setup normally works fine, for 99% of visitors.
>
> However, every day i get a few emails from people who receive an error
> message saying that the session has expired, rather than a successful[/color]
login.[color=blue]
> Each page (including the above frameset page) has an include of
> 'session_check.php'.
>
> The contents of the file is:
>
> <?
> if ($logged_in != session_id())
> {
> echo "<script>self.location='error.php?error=2'</script>";
> exit();
> }
> ?>
>
> For nearly all visitors, the above setup works fine.
>
> Any ideas why some people are told straight after successfully logging in
> that their session has expired? This is really worrying. I can't figure it
> out.
>
> Have I not set up the sessions correctly?
>
> PHP - Version: 4.3.1
>
>[/color]


Closed Thread


Similar PHP bytes