Reply to Re: Warning: session_start(): Cannot send session cookie - headers already sent i

Your name:

Reply:


Posted by Gordon Burditt on 07/13/05 19:29

>I am running PHP Version 4.3.11 with Apache 2.0.54 on XP Pro.
>When I do a session_start(); I am getting
>Warning: session_start(): Cannot send session cookie - headers already
>sent in C:\apache\htdocs\sessionTest.php on line 2
You are sending data before the session_start() call. Don't do
that. This includes blank lines, warning messages, and any text.
Move the session_start() call earlier.

>
>
^^^ If this is line 2, it's a blank line outside <?php, and it's
causing your problem. Get rid of it.

><?php
>session_start();
>if ($_SESSION["last_visist"]){
>echo "Date of las visit: ";
>echo date("j F Y, H:i:s", $_SESSION["last_visit"]);
>echo "<br>";
>}
>else
> echo "This is your first visit";
> $_SESSION["last_visit"] = time();
> $_SESSION["num_visits"]++;
>?>
>
>Any suggestion... please

This obviously isn't the real code. The variety of ways you spell
"last" and "visit" make that obvious. Did you want braces around
the statements after the "else"? What is on line 2?

Gordon L. Burditt

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация