Session problem

I have written a session script for a forum. Now I want to adapt it slightly for a new forum. It works perfectly well. It is just not working though. As a last resort I copied the original files onto the new directory (where the new forum is). Its just the same files with one minor change … I changed the redirect script - so it redirects to the new directory.

Nothing complicated - yet when I use the same session code it doesn’t work. I am using notepad++ and I have set it to UTF8 without a BOM. I set the editor to default at this setting too … yet it still doesn’t work

I have just changed one line of code… which relates in no way to the session… yet it fails

You are going to have to post your code and any error messages you get.

Well I have rewritten the script but it still doesn’t work. here it is

Well this is the script in the first page. Its basically a script to log me in as administrator


<?php
session_start(); 
$_SESSION['loggedin']='yes';
$_SESSION['un']='UncleSirBobby';

echo "username ".$_SESSION['un']. " logged in =".$_SESSION['loggedin'];
$stringg="<img src='loader.gif'>Redirecting<META HTTP-EQUIV='Refresh' CONTENT='01; URL=http://www.scarboroughsmaritimeheritage.org.uk/maritimeforum/listposts.php?id=1'>";
echo $stringg;

?>

this is the code in the second page… listposts.php which is the page the first page redirects to


<?php
session_start(); 

if(isset($_SESSION['loggedin']))
{
echo $_SESSION['loggedin'].$_SESSION['un'];
$logged=$_SESSION['loggedin'];
if($logged=='yes')
{
$userstr="You are logged in as".$_SESSION['un'] ;
}
else
{
$userstr="You are not logged in - <a href='login.php'><img src='login.gif' alt='LOGIN'></a>";
}
}
else
{
$_SESSION['loggedin'] = 'no';
$userstr="You are not logged in - <a href='login.php'><img src='login.gif' alt='LOGIN'></a>";
}


echo $userstr;


?>

I’m guessing your getting an error about headers having already been sent, have you a BOM at the start of the file? Are you outputing anything before the first script in your post is run?

I have had problems with BOMS before. I now use notepad++ which by default is set to UTF8 without a bom. This is the first script - indeed only script on the page. There is no html added to it yet. I just reduced it to the bare bones