Is true that you cannot create session if you are using XAMP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Is true that you cannot create session if you are using XAMP

Postby arpitvavadia » 16. September 2008 07:20

While I am trying to create a session in PHP using following code , I get following error . Can any one help me :roll:

<?php
//first page
echo "Creating Session ";
session_start();

//register some session variables

$_SESSION ['username'] = "arpit";
$_SESSION['role'] = "admin";
?>


Creating Session
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\trial\SES1.PHP:3) in C:\xampp\htdocs\trial\SES1.PHP on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\trial\SES1.PHP:3) in C:\xampp\htdocs\trial\SES1.PHP on line 4

My PHP .ini has following settings
session.save_path = "C:\xampp\tmp"
arpitvavadia
 
Posts: 2
Joined: 16. September 2008 07:16

Postby Wiedmann » 16. September 2008 07:53

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\trial\SES1.PHP:3) in C:\xampp\htdocs\trial\SES1.PHP on line 4

There is an echo() statement and/or other output before session_start().
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby EnglishRocker » 16. September 2008 11:31

You can't output anything before you send headers like session_start() or header(). Try this:

Code: Select all
<?php
session_start();
echo "session created";

// session variables, etc.

?>
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07


Return to XAMPP for Windows

Who is online

Users browsing this forum: strongbrain2007 and 155 guests