ID: 24144
Updated by: [EMAIL PROTECTED]
Reported By: lehel at bin dot hu
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Linux 2.4.8
PHP Version: 4.3.2
New Comment:
You're always unconditionally setting the two sessions variables:
$_SESSION["UserID"]=-1;
$_SESSION["lastactive"]=time ()-4000;
Sounds like a script error -> bogus
Previous Comments:
------------------------------------------------------------------------
[2003-06-12 04:40:45] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24144&edit=1