Jump to content
MakeWebGames

Recommended Posts

Posted

I'm trying to code my login page so if the user goes to www.mysite.com/login.php and they are already logged in, it will rediect them to index.php

Guess I should use something like:

if($_SESSION['loggedin']==0) { header("Location: index.php");exit; }

 

How would I reverse that?

if($_SESSION['loggedin']==1) { header("Location: index/");exit; }

But that doesn't work, any help would be much appreciated.

Thanks

Posted

Re: If logged in redirect help

you are making the wrong assumption...

The user is already logged, goes to index.php

if($_SESSION['loggedin'])

{

header("Location: index.php");

exit;

}

User is not logged, goes to login.php

else if(!$_SESSION['loggedin'])

{

header("Location: login.php");

exit;

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...