Jump to content

Showing a user login to my website


Guest jay4five
 Share

Recommended Posts

Guest jay4five

Hey all, a newbie here...I`m struggling big time with this query....Currently i have a login link/text on my website which takes the user to a login page. Now what i would like to do is, when the user has logged in, the log in link/text would change to logout (which would then log them out). I don`t want the pages to be restricted, i just want to show that they have logged into the site.How do i go about this ?Pleassssse help.RegardsJay

Link to comment
Share on other sites

You could set a cookie when they log in , destroy it when they log out, and dynamically display text based upon existance of that cookie.

<? if (!$_COOKIE[login] == "loggedin") {    echo "Log in";    // the page you would log in to would be where you set the cookie}if ($_COOKIE[login] == "loggedin") {    echo "Log out";    setcookie("login", time()-3600)     // this sets the cookie to have expired an hour ago, deleting it and displaying the log in text when they visit the page again}?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...