php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29103 header("location...") doesn't work after saving a session variable.
Submitted: 2004-07-12 04:10 UTC Modified: 2004-07-14 14:02 UTC
From: allenr at houston dot rr dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: allenr at houston dot rr dot com
New email:
PHP Version: OS:

 

 [2004-07-12 04:10 UTC] allenr at houston dot rr dot com
Description:
------------
Using Apache/1.3.29, the header("location...") feature doesn't work after saving a session variable.  I have two php scripts, login and logout.  In logout, I destroy the session with session_destroy() then use the redirect to get back to the starting page.  This works fine.  In the login script, I verify credentials then set a session variable to indicate the user is logged in, then try the exact same redirect to the index page, this doesn't work. I've tried using "Location: http://www.google.com/" which doesn't work either.  I've also entered the absolute paths to the proper scripts on my own site with the same result.


Reproduce code:
---------------
logout.php - works
------------------
<?php
if (!session_id()) session_start();
if (isset($_SESSION['loggedIn'])) session_destroy();
header("Location: index.php");
?>

login.php excerpt - broken
--------------------------
if (!strcmp($row['password'], $thisPassword) && ($row
     ['type'] == 1)) {
  $_SESSION['blah'] = true;
  header("Location: index.php");
  exit();
}

Expected result:
----------------
I expect to be redirected to the page indicated in the Location header.

Actual result:
--------------
The system seems to ignore the header script altogether, displaying a blank screen when it hits the exit() call.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-14 14:02 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Ask questions about using PHP on php-general@lists.php.net
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 26 07:00:01 2025 UTC