Hi,
I am using header("Locatio n: in two places in my script, but they are
in mutually exclusive blocks i.e if one runs, the other can't.
However, an error is thrown pointing to the session_destroy () line
saying it started output. But it's not being called!
I removed the header() line below session_destroy () but it still gives
the same error so it seems to be session_destroy () existing in the
script even if not called.
if($loginmode== "logout")
{
$_SESSION=array ();
if(isset($_COOK IE[session_name()]))
{
setcookie(sessi on_name(),'',ti me() -42000,'/');
}
session_destroy ();
header("Locatio n: index.php");
exit;
}
// Another bhlock that can't run if the first block has......
if($errorMessag e=="")
{
// Set the $_SESSION variables for this logon
$_SESSION['loginuser']=$row['username'];
$_SESSION['loginlevel']=$row['level'];
header("Locatio n: index.php");
exit;
}
How can I write the php script so that multiple header("Locatio n:
options are present, or can co-exist with session_destroy () ? 2 1319
On 9 Jun, 13:35, mercedes1954 <alandam...@hot mail.comwrote:
Hi,
I am using header("Locatio n: in two places in my script, but they are
in mutually exclusive blocks i.e if one runs, the other can't.
However, an error is thrown pointing to the session_destroy () line
saying it started output. But it's not being called!
I removed the header() line below session_destroy () but it still gives
the same error so it seems to be session_destroy () existing in the
script even if not called.
if($loginmode== "logout")
* * * * {
* * * * $_SESSION=array ();
* * * * if(isset($_COOK IE[session_name()]))
* * * * * * * * {
* * * * * * * * setcookie(sessi on_name(),'',ti me() -42000,'/');
* * * * * * * * }
* * * * session_destroy ();
* * * * header("Locatio n: index.php");
* * * * exit;
* * * * }
// Another bhlock that can't run if the first block has......
if($errorMessag e=="")
* * * * {
* * * * // Set the $_SESSION variables for this logon
* * * * $_SESSION['loginuser']=$row['username'];
* * * * $_SESSION['loginlevel']=$row['level'];
* * * * header("Locatio n: index.php");
* * * * exit;
* * * * }
How can I write the php script so that multiple header("Locatio n:
options are present, or can co-exist with session_destroy () ?
Not that I doubt you or anything, but what precisely stops the second
block from running if the first one has run? Why can't there be
something in $errorMessage just because $loginmode=="lo gout"?
Also, the complete error message will detail 2 lines, the one where
output was started and the one that is trying to send more headers. Is
the second reference to the header() line directly below the
session_destroy ()?
Also, looking at your code in the first block, you seem to check for
the presence of a session by checking for $_COOKIE[session_name()].
However, even if you do not find this cookie, you still invoke
session_destroy (). I would expect thhis to give an error along the
lines of "Trying to destroy uninitialized session..." and this would
certainly be some "output already sent".
On Jun 9, 2:16*pm, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 9 Jun, 13:35, mercedes1954 <alandam...@hot mail.comwrote:
Hi,
I am using header("Locatio n: in two places in my script, but they are
in mutually exclusive blocks i.e if one runs, the other can't.
However, an error is thrown pointing to the session_destroy () line
saying it started output. But it's not being called!
I removed the header() line below session_destroy () but it still gives
the same error so it seems to be session_destroy () existing in the
script even if not called.
if($loginmode== "logout")
* * * * {
* * * * $_SESSION=array ();
* * * * if(isset($_COOK IE[session_name()]))
* * * * * * * * {
* * * * * * * * setcookie(sessi on_name(),'',ti me() -42000,'/');
* * * * * * * * }
* * * * session_destroy ();
* * * * header("Locatio n: index.php");
* * * * exit;
* * * * }
// Another bhlock that can't run if the first block has......
if($errorMessag e=="")
* * * * {
* * * * // Set the $_SESSION variables for this logon
* * * * $_SESSION['loginuser']=$row['username'];
* * * * $_SESSION['loginlevel']=$row['level'];
* * * * header("Locatio n: index.php");
* * * * exit;
* * * * }
How can I write the php script so that multiple header("Locatio n:
options are present, or can co-exist with session_destroy () ?
Not that I doubt you or anything, but what precisely stops the second
block from running if the first one has run? Why can't there be
something in $errorMessage just because $loginmode=="lo gout"?
Also, the complete error message will detail 2 lines, the one where
output was started and the one that is trying to send more headers. Is
the second reference to the header() line directly below the
session_destroy ()?
Also, looking at your code in the first block, you seem to check for
the presence of a session by checking for $_COOKIE[session_name()].
However, even if you do not find this cookie, you still invoke
session_destroy (). I would expect thhis to give an error along the
lines of "Trying to destroy uninitialized session..." and this would
certainly be some "output already sent".- Hide quoted text -
- Show quoted text -
Thank you for the quick response. My brain tricked me into looking at
line 19 - where session_destroy () is - instead of realising it was
line 19 of a small include file that had 2 blank lines after the ?>
Now how many times did I read that in countless posts before turning
here for help???
Thanks for the other comments, but it was a vastly cut down piece of
code and the original addressed your concerns.
Thanks again for your time. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dariusz |
last post by:
I have a problem where when I run the PHP code offline, there are no errors
produced and the code runs as expected. However when I uploaded the same
script and run it, it says the headers have already been sent.
The script is for a "downloader" type script, where the user clicks on a
file link (to the PHP script) using $_GET to pass the selected files ID to
the script, and the information about the file is read out from a database,
also...
|
by: Douglas F. |
last post by:
My host doesn't use buffering so I placed the form validation (php) ahead of
the html like this:
<?php
if(isset($_POST)) {
<do the validation processing>
if(file_exists($fn)) {
header("Location: $fn"); <---Bombs
}
}
|
by: Philip Ronan |
last post by:
OK, here's my 2p worth:
===
Q. Why am I getting the error message 'Headers already sent'?
A. PHP produces this error message when you try to set a header for a web
page after you have already started sending out the content of the page.
Web content is always delivered with a few headers at the top, ending with a
blank line. For example, a web page might start like this:
|
by: lkrubner |
last post by:
I'm getting this error:
Warning: session_start(): Cannot send session cache limiter - headers
already sent in
/home/httpd/vhosts/publicdomainsoftware.org/httpdocs/pdsIncludes/McSessionInfo.php
on line 34
This is line 33 to line 36 of that class:
|
by: Andreas Klemt |
last post by:
Hello,
I get this error Message "cannot redirect after http headers have been sent"
when I do this
response.redirect ("home.aspx")
How can I find out with vb.net if already a http header has been sent like
If response.IsSentHttpHeader then
....
| |
by: Andreas Klemt |
last post by:
Hello,
I get this error Message "cannot redirect after http headers have been sent"
when I do this
response.redirect ("home.aspx")
How can I find out with vb.net if already a http header has been sent like
If response.IsSentHttpHeader then
....
|
by: Platero |
last post by:
Hi,
I've a stupid question but...
The code is the following:
if(($role!='tutor')&&(array_key_exists('tutor_id',$_GET)))
{
$possible_ids = array(2,6,7,8,9,10);
$t_id = $_GET;
|
by: craigtomo |
last post by:
I am getting the following error when i try to log on to my data base
Warning: session_register() : Cannot send session cookie - headers already sent by (output started at D:\virtualservers\182763\root\test\login\checklogin.php:1) in D:\virtualservers\182763\root\test\login\checklogin.php on line 18
Warning: session_register() : Cannot send session cache limiter - headers already sent (output started at...
|
by: Markus |
last post by:
Things to discuss:
Headers
What are they?
What does PHP have to do with headers?
Why can they only be sent before any output?
Common causes
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |