using session_start() on the server

Alles, was PHP betrifft, kann hier besprochen werden.

using session_start() on the server

Postby Murph » 21. November 2008 12:08

Hi i wonder if someone can help. I have the following file. I tested it on XAMPP Apache and works ok. But when i load the same on the server it shows errors. Just to say the <?php tag is on the first line of the file.
<?php
// begin the session
session_start();

// set the value of the session variable 'foo'
$_SESSION['foo']='bar';

// echo a little message to say it is done
echo 'Setting value of foo';
?>
And the errors that show are:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Domains\mywebsite.com\wwwroot\login.php:1) in C:\Domains\mywebsite.com\wwwroot\login.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Domains\artcadia.org\wwwroot\login.php:1) in C:\Domains\artcadia.org\wwwroot\login.php on line 3

Hope someone can help.

M.
Murph
 
Posts: 17
Joined: 30. September 2008 18:51

Postby glitzi85 » 21. November 2008 20:18

Do you call the PHP-Script directly (http://example.com/login.php)?

Is there maybe a blank before <?

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Errors

Postby Murph » 22. November 2008 13:22

I uploaded the file to my website as a test and had a link to it from one of my other pages. But it showed errors. There is no blank before the < mark. It does not show any errrors when i try it on Apache on my computer.

Really hope you can help. Thanks.

M.
Murph
 
Posts: 17
Joined: 30. September 2008 18:51

Postby Nobbie » 22. November 2008 13:57

If youre local Apache has output buffering activated, the problem will not appear.

I think, that the problem itself is due to the well known "BOM UTF8" header, read this for example: http://www.usenet-forums.com/php-genera ... eader.html
Nobbie
 
Posts: 8765
Joined: 09. March 2008 13:04

Postby Murph » 23. November 2008 16:28

I am only new to PHP and i don't know what BOM is. The other forum thread you posted i don't know how it helps.

Hoping someone can help.

Kind Regards,
M.
Murph
 
Posts: 17
Joined: 30. September 2008 18:51

Postby Nobbie » 23. November 2008 16:33

>I am only new to PHP and i don't know what BOM is. The other forum thread you posted i don't know how it helps.

Obviously, you did not read that article carefully, because it also contains a further link to a complete documentation what "BOM" is.

Read it again and click on that further link, or enter "Byte Order Mark" (= BOM) into Google and read the documentation you find there.
Nobbie
 
Posts: 8765
Joined: 09. March 2008 13:04

Many thanks

Postby Murph » 24. November 2008 14:12

Thanks a million. I reread the post you sent and learned what BOM is. Thanks. I also downloaded the Notepad++ and saved php file without BOM. Thanks again for your help Nobbie. I apologise for not ready your post more carefully.

Kind Regards,

M.
Murph
 
Posts: 17
Joined: 30. September 2008 18:51


Return to PHP

Who is online

Users browsing this forum: No registered users and 3 guests