php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25238 session has problems starting
Submitted: 2003-08-25 13:00 UTC Modified: 2003-08-25 18:57 UTC
From: jeffrea at dslextreme dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.2 OS: Win2k server sp4
Private report: No CVE-ID: None
 [2003-08-25 13:00 UTC] jeffrea at dslextreme dot com
Description:
------------
Session will not start without manual manipulation.  I use session to ensure only authorized people are loged in to do back end processing.  When anyone attems to logon it just kicks them back to the logon page even though there info is correct.  So I point them to a different page with no redirection.  Which should display there session info 
   session_start();

   echo $_SESSION['user'];
   echo $_SESSION['pass'];

But nothing is displaied.  If you click on the back button reinput the same logon credentials You go back to the page again and it will then work??????  So at  this point I change the redirection of the logon page to point to were it should and it works fine until the next time I login and I have to repeat this again.  Any idea?

Reproduce code:
---------------
session_start();

if (!$_SESSION['user'] || !$_SESSION['pass']) {

header('Location: logon.php');
die();

} else {

$db = mysql_connect('localhost', 'xxxxx', 'xxxx') or die("Couldn't connect to the database.");
mysql_select_db('addissalsa') or die("Couldn't select the database");

$result = mysql_query("SELECT count FROM users WHERE password='$_SESSION[pass]' AND username='$_SESSION[user]'") or die("Couldn't query the user-database.");
$num = mysql_result($result, 0);

if (!$num) {

header('Location: login.php');
die();
}
}

Expected result:
----------------
I expect that the session would start and that the rest of the code on the page would run but it is being redirect back to the logon.php from the 
if (!$_SESSION['user'] || !$_SESSION['pass']) {

header('Location: logon.php');
die();



Actual result:
--------------
redirected to logon.php  



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-25 18:57 UTC] sniper@php.net
You're propably doing something wrong. This works just fine for me and thousands of others when done correctly.
(first obvious error: "Location:" header expects full URL)

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Feb 04 06:00:01 2026 UTC