I need a script that replaces "login" with "logout" when im logged in and vice versa. Anyone know of a god tutorial that teaches how to do this?

Assuming you have created a session then all you need to do is check whether or not it has been set, like so:


if(isset($_SESSION['SESSION_NAME'])) {

    ?> <a href = "/Logout.php" > Logout </a> <?php


if(!isset($_SESSION['SESSION_NAME'])) {

    ?> <a href = "/Login.php" > Login </a> <?php



What this is doing is saying, if a session has been created then it should display logout but if it hasn't then it shall display login.

AHarrisGsy is right, upvote for that. I'll just to simplyfy it a little bit:

if(isset($_SESSION['SESSION_NAME'])) {
    echo '<a href = "/Logout.php" > Logout </a>';
} else {
    echo '<a href = "/Login.php" > Login </a>';

sweet thanks for the replies. How would i set up that script to also logout when logout is clicked?

Simple unset your session, so when it goes to your Logout.php page you would have something like this: