Jump to content

Session Error


fabs
 Share

Recommended Posts

i made a session script like this

<?php session_start(); ?> <html> <head> <title>Listing 20.1 Starting or resuming a session</title> </head> <body> <?phpprint "<p>Welcome, your session ID is ".session_id()."</p>\n\n"; ?> </body> </html>
but it result an error like this
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/w3school_trying/session.php:2) in /var/www/w3school_trying/session.php on line 3Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/w3school_trying/session.php:2) in /var/www/w3school_trying/session.php on line 3Welcome, your session ID is 9e755313bf0afe34f3ca33c496942fce
how to solve this problem????
Link to comment
Share on other sites

First of all make sure that NO other outputs are made before executing session_start. What do you get if you leave the file empty exept:
<?phpsession_start();echo session_id();?>

i have made the script above andit still gotan error
Link to comment
Share on other sites

Do you have anything above that code? Are you trying to include that code, or do you have some prefixes* defined in Apache? If you view the resulting HTML code, what do you see?* can't remember the technical term

Link to comment
Share on other sites

This line tells you where the output is:Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/w3school_trying/session.php:2) in /var/www/w3school_trying/session.php on line 3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...