469,330 Members | 1,329 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Why can't I use session

Hi,

When I run this script:

<?php
session_start();
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.session-start]: Cannot send session cache
limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart
What is wrong?

Ricki
Jul 17 '05 #1
4 46849
Ricki Susic wrote:
Hi,

When I run this script:

<?php
session_start();
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart
What is wrong?

As the error says: You are sending things before you do your sessionstuff.
Solution: don't. Put you sessionlogic on top of the page.

Regards,
Erwin Moller
Ricki


Jul 17 '05 #2
With total disregard for any kind of safety measures Erwin Moller
<si******************************************@spam yourself.com>
leapt forth and uttered:
As the error says: You are sending things before you do your
sessionstuff. Solution: don't. Put you sessionlogic on top of
the page.


Actually you just need to make sure you call session_start() before
any output.
--
There is no signature.....
Jul 17 '05 #3
On Mon, 29 Sep 2003 11:52:27 -0500, Phil Roberts wrote:
<snip!>
Actually you just need to make sure you call session_start() before any
output.


Including whitespace!

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 17 '05 #4
Ricki Susic wrote:

Hi,

When I run this script:

<?php
session_start();
$_SESSION['test'] = "Session er smart";
echo $_SESSION['test'];
?>

I get this error-message:

Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10

Warning: session_start() [function.session-start]: Cannot send session cache
limiter - headers already sent (output started at
/hotel/svp/WWW/html/php/auth.php:9) in /hotel/svp/WWW/html/php/auth.php on
line 10
Session er smart

You can't send anything to the browser before starting your session, not even a
single blank line or space. Make sure your file starts like this:

-------------Start of file---------------------
<?PHP
session_start();

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by tshad | last post: by
9 posts views Thread by charliewest | last post: by
14 posts views Thread by aroraamit81 | last post: by
2 posts views Thread by lookee | last post: by
reply views Thread by TRB_NV | last post: by
11 posts views Thread by Bocah Sableng | last post: by
11 posts views Thread by cybervigilante | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.