|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-06-12 04:40 UTC] lehel at bin dot hu
Description:
------------
This script is for logging in a user on a page.
After the query $_SESSION variables are set according to the values stored in the database, I've checked them by echoing them.
But when checking the same variables in start.php they contain the pre-set values that were set at the beginning of this script.
After going back to the index script, and starting all over the login procedure, the results are as expected.
It seems so that the session engine does not handle multiple value changes in the script where session_start is used at the first time on the page, bcause the usage of session_start on the submitting page solves the problem.
db_Exec and db_Result are simple database wrappers.
Reproduce code:
---------------
session_start ();
include_once ("Include/Common.php");
$_SESSION["UserID"]=-1;
$_SESSION["lastactive"]=time ()-4000;
$dbconn=db_Connect ();
$query=db_Exec ($dbconn,"SELECT * FROM users WHERE username='$_POST[UserName]' AND userpwd='$_POST[UserPwd]';");
if (db_Num_Rows ($query)==0) {
nupi_error ("Jelsz?, vagy felhaszn?l?n?v hiba!");
}
$row=db_Fetch_Row ($query);
$_SESSION["UserID"]=$row["user_id"];
$_SESSION["lastactive"]=time ();
header ("Location: start.php");
Expected result:
----------------
$_SESSION["UserID"] = 0
$_SESSION["lastactive"] ... actual time
in start.php
Actual result:
--------------
$_SESSION["UserID"] = -1
$_SESSION["lastactive"] ... actual time-4000
in start.php
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 15:00:01 2025 UTC |
You're always unconditionally setting the two sessions variables: $_SESSION["UserID"]=-1; $_SESSION["lastactive"]=time ()-4000; Sounds like a script error -> bogus