[PHP] Session and header()

2001-11-21 Thread Jordan Elver

Hi,
I've got a login script that uses sessions. To end a login session, I simply 
delete the session variables and do a session_destroy() which seems to logout 
everyone ok. The problem comes when I do a header() call afterwards to 
redirect after logging out.

It seems the header() call stops my logging out working correctly?! Does 
anyone have an idea of why header would interfere with seesion functions?

Thank,
Jordan
-- 
Jordan Elver
http://www.jordanelver.co.uk
"testing? What's that? If it compiles, it is good, if it boots up it is 
perfect." --- Linus Torvalds

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Session and header() errrors

2001-10-04 Thread Naintara Jain

There are 2 things you are doing here:
1) Session start
2) page redirection

put session_start() as the 1st line in your script.
Echo commands in the included file causes such warnings:
"Warning: Cannot send session cookie - headers already sent by (output
started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)"

The first two warnings are on account of the above problem.

The 3rd warning is becoz of the php.ini that Dimitris talks about.

For the last warning, another simple mistake:
<---echo "session_id: ".session_id()."";-->
comment this line and then redirect the page.

the header() function will cause errors if you have already written, sent output 
('echoed', etc) to
the current page.

-Naintara


- Original Message - 
From: "Dimitris Kossikidis" <[EMAIL PROTECTED]>
To: "Web user" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, October 04, 2001 4:48 PM
Subject: Re: [PHP] Session and header() errrors


You should change sessions configuration in php.ini

The default value for sessions dir /tmp.
In windows shoud point to c:\tmp

The header error occurs because you get a warning about session.


- Original Message -
From: "Web user" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 04, 2001 11:51 AM
Subject: [PHP] Session and header() errrors


> Why do the errors occur while running the scripts below? It seems that the
> errors occured at the part of session and header(). Please give me some
> advice!
> Thank you!
>
> Mike
>
> System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations
> are default in php.ini)
>
> when the 1.php is running, the IE shows errors info as below :
> -
> Warning: Cannot send session cookie - headers already sent by (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: Cannot send session cache limiter - headers already sent (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: open(/tmp\sess_96ae897bcb501486860552d2df862863, O_RDWR) failed:
m
> (2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
> session_id: 96ae897bcb501486860552d2df862863
>
>
> Warning: Cannot add header information - headers already sent by (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 9
>
> -
> The scripts of 1.php: (1.php and 2.php are under the same base directory)
>  require("html-head.inc");
> session_start();
> $name="user";
> session_register("name");
> echo "session_id: ".session_id()."";
> sleep(10);
> header("Location: 2.php");
> require("html-foot.inc");
> ?>
>
> -
> The scripts of html-head.inc:
> 
> 
> 
> page title
> 
> 
>
> -
> The scripts of html-foot.inc:
> 
> 
>
>
>
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Session and header() errrors

2001-10-04 Thread Dimitris Kossikidis

You should change sessions configuration in php.ini

The default value for sessions dir /tmp.
In windows shoud point to c:\tmp

The header error occurs because you get a warning about session.


- Original Message -
From: "Web user" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 04, 2001 11:51 AM
Subject: [PHP] Session and header() errrors


> Why do the errors occur while running the scripts below? It seems that the
> errors occured at the part of session and header(). Please give me some
> advice!
> Thank you!
>
> Mike
>
> System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations
> are default in php.ini)
>
> when the 1.php is running, the IE shows errors info as below :
> -
> Warning: Cannot send session cookie - headers already sent by (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: Cannot send session cache limiter - headers already sent (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: open(/tmp\sess_96ae897bcb501486860552d2df862863, O_RDWR) failed:
m
> (2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
> session_id: 96ae897bcb501486860552d2df862863
>
>
> Warning: Cannot add header information - headers already sent by (output
> started at c:\program files\apache
group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 9
>
> -
> The scripts of 1.php: (1.php and 2.php are under the same base directory)
>  require("html-head.inc");
> session_start();
> $name="user";
> session_register("name");
> echo "session_id: ".session_id()."";
> sleep(10);
> header("Location: 2.php");
> require("html-foot.inc");
> ?>
>
> -
> The scripts of html-head.inc:
> 
> 
> 
> page title
> 
> 
>
> -
> The scripts of html-foot.inc:
> 
> 
>
>
>
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Session and header() errrors

2001-10-04 Thread Rasmus Lerdorf

You can't send any output before the session_start() call.  You require a
file which outputs html before calling session_start().  Simply do the
session_start() before the require and it should work.

-Rasmus

On Thu, 4 Oct 2001, Web user wrote:

> Why do the errors occur while running the scripts below? It seems that the
> errors occured at the part of session and header(). Please give me some
> advice!
> Thank you!
>
> Mike
>
> System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations
> are default in php.ini)
>
> when the 1.php is running, the IE shows errors info as below :
> -
> Warning: Cannot send session cookie - headers already sent by (output
> started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: Cannot send session cache limiter - headers already sent (output
> started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
>
> Warning: open(/tmp\sess_96ae897bcb501486860552d2df862863, O_RDWR) failed: m
> (2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
> session_id: 96ae897bcb501486860552d2df862863
>
>
> Warning: Cannot add header information - headers already sent by (output
> started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
> in c:\program files\apache group\apache\htdocs\web1\1.php on line 9
>
> -
> The scripts of 1.php: (1.php and 2.php are under the same base directory)
>  require("html-head.inc");
> session_start();
> $name="user";
> session_register("name");
> echo "session_id: ".session_id()."";
> sleep(10);
> header("Location: 2.php");
> require("html-foot.inc");
> ?>
>
> -
> The scripts of html-head.inc:
> 
> 
> 
> page title
> 
> 
>
> -
> The scripts of html-foot.inc:
> 
> 
>
>
>
>
>
>
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Session and header() errrors

2001-10-04 Thread Web user

Why do the errors occur while running the scripts below? It seems that the
errors occured at the part of session and header(). Please give me some
advice!
Thank you!

Mike

System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations
are default in php.ini)

when the 1.php is running, the IE shows errors info as below :
-
Warning: Cannot send session cookie - headers already sent by (output
started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
in c:\program files\apache group\apache\htdocs\web1\1.php on line 3

Warning: Cannot send session cache limiter - headers already sent (output
started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
in c:\program files\apache group\apache\htdocs\web1\1.php on line 3

Warning: open(/tmp\sess_96ae897bcb501486860552d2df862863, O_RDWR) failed: m
(2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 3
session_id: 96ae897bcb501486860552d2df862863


Warning: Cannot add header information - headers already sent by (output
started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)
in c:\program files\apache group\apache\htdocs\web1\1.php on line 9

-
The scripts of 1.php: (1.php and 2.php are under the same base directory)
";
sleep(10);
header("Location: 2.php");
require("html-foot.inc");
?>

-
The scripts of html-head.inc:



page title



-
The scripts of html-foot.inc:











-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]