php - session is not started. but still displaying the error that it has already started -


this question has answer here:

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.

enter image description here

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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -