Page 1 of 1

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

PostPosted: 16. September 2008 07:20
by arpitvavadia
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"

PostPosted: 16. September 2008 07:53
by Wiedmann
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().

PostPosted: 16. September 2008 11:31
by EnglishRocker
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.

?>