Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Anibor

25 posts

Geek


#68955 30-Sep-2010 12:29
Send private message

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\psAdmin\index.php:53) in C:\xampp\htdocs\psAdmin\inc\logincheck.php on line 14

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\psAdmin\index.php:53) in C:\xampp\htdocs\psAdmin\inc\logincheck.php on line 14

the only php that is on my index page is:
               
            $page = $_GET['page'];
            if ($page)
            {
                include("inc/".$page.".php");
            }   
            else
            {
            include("inc/login.php");
            }
           
           
        ?>

but im thinking that somehow this is stopping me from using session_start() on my login page...

Any suggestions?

Create new topic
Kraven
738 posts

Ultimate Geek
+1 received by user: 190


  #386291 30-Sep-2010 12:37
Send private message

What else is on your index page? Is there HTML above the first '<?php' tag?

You should be including session management as one of the first things on your script.



Anibor

25 posts

Geek


  #386298 30-Sep-2010 12:53
Send private message

Yeah theres some html but i wouldnt have thought that would interfer with the php. What is session management?

Im a total noob at php

nate
6473 posts

Uber Geek
+1 received by user: 458

Retired Mod
Trusted
Lifetime subscriber

  #386325 30-Sep-2010 13:51
Send private message

Anibor: Yeah theres some html but i wouldnt have thought that would interfer with the php. What is session management?


Session info (such as cookies) are sent out first in a page request.  What Kraven is saying, is anything you set in the session must be done first, before any print or echo is done to the screen.

If you do have something print to screen and then set something in the session, you will get the errors you are receiving :)



FeralReason
1 post

Wannabe Geek


  #386569 1-Oct-2010 05:53
Send private message

This error is generally caused because, somewhere in your code -- an include file perhaps -- you are calling session_start() after some output has already gone out.  One of the following should solve this problem:

1) Make sure session_start() is called before ANY other information is sent. Place it before any includes.
2) If this doesn't work, create a stripped down test file (basically one that does nothing but the session_start()  ) and test it again. If the stripped down test file does not work, try changing to a different encoding. In my environment "UTF-8 With BOM" DOES NOT WORK, while either "UTF-8 without BOM" or ANSI works fine.
3) If there is some reason (I can't think of one) to output something before calling session_start(), you might try putting ob_start() at the beginning of the file and ob_flush() at the end. This buffers the output and may allow session_start() to work -- but this is more of a work-around than a solution.
4) Using @session_start() does not solve the problem. It simply supresses the warnings so that you don't see them.

Let me know if this does not solve your problem.

Olliepop
1 post

Wannabe Geek
Inactive user


  #389312 7-Oct-2010 19:37
Send private message

Change

session_start()

too


if(!isset($_SESSION))
{
session_start();
$_SESSION['start'] = true;
}


indpurvesh
1 post

Wannabe Geek


  #390397 11-Oct-2010 11:20
Send private message

Usually this happen because you had a echo statement before or  possibly a white pace when you start and end <?php  or ?>  tags.


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.