Click to See Complete Forum and Search --> : Need help with scripting


cns187
04-17-2006, 03:26 PM
hey guys i really need help with this

i need to create a page that will allow users to log out of the site. The page script will kill the sessions so that all Session Variables will be set to NULL.
Before killing the Session, your script should ask the user if he/she really wants to leave the site. If YES then kill the session and return the user to the login page. If the user does not want to leave the site, redirect the user back to the menu page

dont even know where to start :S any help would be greatly appreciated..thank you!

lmf232s
04-17-2006, 03:34 PM
There can be several variations on how to do this but here is an example.

This example calls a javascript function when the user clicks the logout link/button and depending on how the user answers that question will do 1 of 2 things.

<a href="javascript:ConfirmLogout; return false">Log Out</a>

function ConfirmLogout(){
if(confirm(Are you sure you want to log off?')){
windows.location = 'logout.asp';
}else{
windows.location = 'main.asp'; (you could just leave this off and then the user would stay on the same page they are on)
}
}

Then you can just have a logout.asp page that kills the sessions and then redirects the user to the log in screen

logout.asp

<%
Session.Abandon()
Response.redirect "Login.asp"
%>

cns187
04-17-2006, 03:44 PM
does this set the session variables to NULL???

lmf232s
04-17-2006, 05:07 PM
no it terminates the current session.
If you want to set it to null then just set each one to null

Session("Name") = Null

or you could loop them and set all to null

Dim i

For i=1 to Session.Contents.Count
Session.Contents(i) = Null
Next

cns187
04-17-2006, 05:14 PM
thank you for your help greatly appreciated