Issues with frames and sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wro
Forum Newbie
Posts: 2
Joined: Wed May 26, 2010 7:35 am

Issues with frames and sessions

Post by wro »

Hello, I am using two frames, one for navigation and the other for content. The navigation will display news and other information if there is not a session set, the content, once logged in will set the session then reload the menu frame, however it is displaying the following error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (error on line 2 [session_start()]

Code: Select all

<php
session_start();
include 'connect.php';
?>
<?php
if (isset($_SESSION['player'])) 
  {
    echo "<a href=\"overview.php\" target=\"content\"><p align=\"center\">Overview</p></a>";
    echo "<a href=\"town.php\" align=\"center\" target=\"content\"><p align=\"center\">Town</p></a>";
    echo "<a href=\"charsheet.php\" align=\"center\" target=\"content\"><p align=\"center\">Character Sheet</p></a>";
    echo "<a href=\"skills.php\" align=\"center\" target=\"content\"><p align=\"center\">Skills</p></a>";
    echo "<a href=\"market.php\" align=\"center\" target=\"content\"><p align=\"center\">Market</p></a>";
    echo "<a href=\"guild.php\" target=\"content\"><p align=\"center\">Guild Hall</p></a>";
    echo "<p align=\"center\"><img src=\"images/standard.jpeg\" align=\"middle\"></p>";
    echo "<p align=\"center\">HP: xxx/xxx</p>";
    echo "<p align=\"center\">IP: xxx/xxx</p>";
  }
else
  {
    echo "<h2>News:</h2>";
    echo "<p>Frame and menu added 05-26-2010</p>";
    echo "<p>Registration live 05-18-2010</p>";
}
?>
Snippet from the authentication page.

Code: Select all

if($result2)
    {
       session_start();
       $_SESSION['player']=$player;
       print "logged in successfully<br><br>";
       print "<A href='content.php'>Play!</a>";
       print("<script language ='javasript'>top.menu.locatin.reload();</script>");   
    }
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Issues with frames and sessions

Post by Weirdan »

wro
Forum Newbie
Posts: 2
Joined: Wed May 26, 2010 7:35 am

Re: Issues with frames and sessions

Post by wro »

Sorry, I suppose I should have noted that I had already searched for the solution, as you can see from the code, there is no white space before the session_start, and I believe the problem may be that I'm trying to implement the same session in both frames? I've tried naming the sessions but that didn't work either and I'm feeling a bit stuck.
Post Reply