Changing the login link to logout

They have: 16 posts

Joined: Mar 2001

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's picture

He has: 4,048 posts

Joined: Aug 2000

post the code you have for this

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.

<?php
If Session("login") = 1 then
     Session
("login") = 0
?>

Logout
<?php
Else
    
Session("login") = 1
?>

Login
<?php
End
If
?>

Mark Hensler's picture

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.