I've got a big problem on my site i'm developing. I have a pretty simple session login script, and every page of my site checks to see if the person is logged in. If not, it redirects them to login.php.

I've noticed that when I click links on my menu bar to go back to index.php or whatever, for some reason it automatically logs me out and yanks me over to login.php.

It doesnt make sense because when I point my browser to index.php instead of clicking the link, it does fine with no log out problems.

links:

<nav><ul> 
			<li><a href="http://mysite.com/">home page</a></li> 
			<li><a href="http://mysite.com/search.php">Search</a></li> 
			<li class="active"><a href="http://mysite.com/videos/index.php">Browse</a></li> 
			<li><a href="http://mysite.com/upload.php">Upload</a></li> 
		</ul></nav>

session:

session_start();
$myusername = $_SESSION['myusername'];	
$rank = $_SESSION['rank'];

if($myusername != NULL){
$loggedin = true;	
}else{
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=http://mysite.com/login.php\">";
}

Any ideas of whats going wrong? Thanks so much!

I figured this one out on my own :)

If anyone has this problem in the future, the fix is to make sure you have "www." included in your links. Apparently this enables info to be carried over to the next page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.