Jump to content

problem with login / logout


jobs1109

Recommended Posts

Hi,

 

I am having a bit of problem with my login/logout script. When user is logged in I want the script to show logout and if they are not login I want the script to show login. The problem is even when the user is logged in it says "you must be logged in Click here to login " here is the script Please help

 



<?php
session_start();
$_SESSION['username'] = $_POST['username'];
if ($_SESSION['username'])
echo "Welcome, ".$_SESSION['username']."!<br><a href='logout.php'>Logout</a>" ;
else
die("you must be logged in <a href='Login.php'>Click here to login</a>");
?>

 

what did I do wrong in this script ?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/248400-problem-with-login-logout/
Share on other sites

First, I'm assuming the script we are talking about is ONLY displayed once upon logging in.  If it is used more than once you would need to POST the username to it each time.  Or you would get the results you are talking about.  Probably won't help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.