php - session is not started. but still displaying the error that it has already started -
this question has answer here:
- how fix “headers sent” error in php 11 answers
i included login.php , loggedin.php files in index.php.
both login.php , index.php has no session_start(); , loggedin.php has session_start(); in it.
but still getting following errors when open index.php:
warning: session_start() [function.session-start]: cannot send session cookie - headers sent (output started @ /home/content/98/10855698/html/symp13/index.php:110) in /home/content/98/10855698/html/symp13/loggedin.php on line 2 warning: session_start() [function.session-start]: cannot send session cache limiter - headers sent (output started @ /home/content/98/10855698/html/symp13/index.php:110) in /home/content/98/10855698/html/symp13/loggedin.php on line 2
the loggedin.php follows:
<?php session_start(); if (isset($_session['username'])) { echo 'you logged in as'.' '.$_session["username"]; echo '<form action="upload.php" method="post" enctype="multipart/form-data" name="upload">'.'<input type="file" name="file" /><input type="submit" name="submit" />'.'</form>'; } else { echo 'you need login in account submitting abstract or applying tutorials!'; echo 'click here to'.' '.'<a href="login.php">login</a>'; } ?>
login.php includes form action set login_check.php includes session_start();. dont think problem..because, cant run until form submitted.
and if run loggedin.php in separate file. showing no errors.
i confused. please tell me how solve , cause.
as the documentation says:
to use cookie-based sessions, session_start() must called before outputing browser.
this means there must no whitespace before call session_start()
, whitespace. so, index.php file must this:
<?php include 'loggedin.php'; //containing session start include 'login.php'; echo 'other output'; ?> more output here
Comments
Post a Comment