Re: [PHP] Warning: Cannot send session cookie
On Tuesday 04 October 2005 08:15 pm, John Taylor-Johnston wrote: > Any idea why I'm getting this error, and only on this page? I have the > same header on every other page? > http://testesp.flsh.usherb.ca/thingstodo.html > The page contains a \n before I start my > session_name( 'CCLTrolley' ); > session_start(); > > // Initialize the trolley. > if( !isset( $_SESSION['TrolleyContents'] ) ) > { > $_SESSION['TrolleyContents'] = array(); > } > ?> > > Warning: Cannot send session cookie - headers already sent by (output > started at /var/www/html2/thingstodo.html:2) in > /var/www/html2/thingstodo.html on line 4 > Warning: Cannot send session cache limiter - headers already sent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning: Cannot send session cookie
Michael Crute wrote: The page contains a \n before I start my That \n is it. You can't send ANYTHING to the browser before you send the headers and cookies are part of the headers. Take out the \n and all should be well. Thanks. Dreamweaver screwed me over ;)
Re: [PHP] Warning: Cannot send session cookie
John Taylor-Johnston wrote: Any idea why I'm getting this error, and only on this page? I have the same header on every other page? http://testesp.flsh.usherb.ca/thingstodo.html The page contains a \n before I start my Most likely, yes. Why didn't you try removing it before posting to the list? Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html2/thingstodo.html:2) in /var/www/html2/thingstodo.html on line 4 Warning: Cannot send session cache limiter - headers already sent -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning: Cannot send session cookie
take the closing php tag from the end of the first line plus the openning tag from the begining of the second line. that is sending a line feed to the browser. Jim - Original Message - From: "David Jackson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 26, 2001 5:54 PM Subject: [PHP] Warning: Cannot send session cookie > Greetings -- > PHP + MySQL + sessions? > > I'm trying use the script( and html page) to below to set session > variables, but > keep getting the follow errors: > NOTE: I seen several posting re: using $HTTP_SESSION_VAR is another case > where > that would apply? > > Thanks in advance, > David Jackson > > > Browser Error Messages - > Warning: Cannot send session cookie - headers already sent by (output > started at > /home/sites/site13/web/connect.php:13) in > /home/sites/site13/web/frontdesk/sales/login.php on line 15 > > Warning: Cannot send session cache limiter - headers already sent (output > started at > /home/sites/site13/web/connect.php:13) in > /home/sites/site13/web/frontdesk/sales/login.php on line 15. > > > --- login.php - > > > > $result = mysql_query("SELECT uid,uname,uperms FROM guestusers > WHERE uname = '$uname' >AND upass = PASSWORD('$upass')"); > > if (mysql_num_rows($result)!=1) { > echo "Dis ain't good !!\n"; > > mysql_free_result ($result); > mysql_close($link); > > } else { > // start session > session_start(); > session_register("Uid"); > session_register("Uname"); > session_register("Uperms"); > > // parse out query output and resign to session vars > list($uid,$uname,$uperms) = mysql_fetch_row($result); > $Uid = $uid; > $Uname = $uname; > $Uperms = $uperms; > > // redirect to main menu page > mysql_free_result ($result); > mysql_close($link); > > > > - login.html > > > Generic Time Tracker > > Sales Entry Login screen: > > > > Username: > > > > Password > > > > value="Enter"> > > > > > > > -- > > > > -- > 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] Warning: Cannot send session cookie
At 08:54 PM 12/26/2001 -0500, David Jackson wrote: >I'm trying use the script( and html page) to below to set session >variables, but >keep getting the follow errors: [...] > Browser Error Messages - >Warning: Cannot send session cookie - headers already sent by (output >started at [...] Cookies are set and read via HTTP headers, therefore this has to occur before any output is sent to the client. You can work around this with the ob_start() and ob_end_flush() functions, but normally you'd want to move the session_start() or session_register() calls up to the top of your script. See below: "Note: If you are using cookie-based sessions, you must call session_start() before anything is output to the browser." http://www.php.net/manual/en/function.session-start.php "Note: In PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files." http://www.php.net/manual/en/function.header.php -- 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]