This is a discussion on Why can't I use session within the PHP Language forums, part of the PHP Programming Forums category; Hi, When I run this script: <?php session_start(); $_SESSION['test'] = "Session er smart"; echo $_SESSION['test']; ?> ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
With total disregard for any kind of safety measures Erwin Moller
<since_humans_read_this_I_am_spammed_too_much@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..... |
|
|||
|
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/ |
|
|||
|
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 shawn@glassgiant.com http://www.glassgiant.com |