Changing the login link to logout
My website allows users to login and access restricted pages. What should I do so that when a user logs in, my login link will automatically change to logout?
I tried using Session variables to track if the user has logged in. Unfortunately, the login link does not change to logout.
Help!
Mark Hensler posted this at 18:47 — 6th April 2001.
He has: 4,048 posts
Joined: Aug 2000
post the code you have for this
val04 posted this at 03:41 — 8th April 2001.
They have: 16 posts
Joined: Mar 2001
I placed this code in Bottomnav.asp. Bottomnav.asp is displayed on a frame at the bottom part of all my pages. It contains several links including the login link.
<?phpIf Session("login") = 1 then
Session("login") = 0
?>
Logout
<?phpElse
Session("login") = 1
?>
Login
<?phpEnd If
?>
Mark Hensler posted this at 18:55 — 8th April 2001.
He has: 4,048 posts
Joined: Aug 2000
Try printing the state of the login variable.
Also, to kill the session, you'll want to use Session.Abandon
<%response.write "<!--login:" & Session("login") & "-->" & vbCrLf
If Session("login") = 1 then
Session("login") = 0
Session.Abandon 'kill the session
response.write "<a href=""Bottomnav.asp"">Login</a>"
Else
Session("login") = 1
response.write "<a href=""Bottomnav.asp"">Login</a>"
End If
%>
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.