Login/Logout Question

liquid22
liquid22 used Ask the Experts™
on
I've built an login / admin area on our company intranet site and I'm having problems with the logout functionalitiy...basically I don't have a logout page and I'm not sure how to code it.  

My Application.cfm file has the following code:
<cfapplication name="EmployeeSearch"
ClientManagement="No"
Sessionmanagement="Yes"
SessionTimeout="#createtimespan(0, 0, 30, 0)#"
SetClientCookies="Yes">

My login page has various codes but it sets the session with:
<CFSET Session.Auth = 'Yes'>
<CFSET Session.Admin = "#Form.UserName#">

Each protected page has the following code as well and it works if I try to access each page directly without logging in:
<CFIF isDefined("Session.Auth") is NOT TRUE>
<CFLOCATION url="../login.cfm">
<CFELSE>
html code
</CFIF>

I have a logout page that sets the Session.Auth to No but that doesn't seem to do what I want.  Any ideas where I'm going wrong?  I'm sure this is a simple fix.  Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try changing the line <CFIF isDefined("Session.Auth") is NOT TRUE>

to

<CFIF Not isDefined("Session.Auth") or #Session.Auth# eq "No">

This should then trigger the login code when one has logged out.

Author

Commented:
I don't think that really helps my situation.  the <CFIF isDefinied("Session.auth") is NOT TRUE> is working fine...if the user is not logged in they will get redirected to a login page.  What I need is based on the code, I want a link that reads "LOGOUT".  When they click it, I want it to kill their session or cookie and redirect them to the login page.  But what I don't know is what to put on the logout page that will end all of that stuff and basically reset the session back to the beginning.
<cfscript>structClear(Session);</cfscript>

This will clear the session for the current user.

Author

Commented:
That did it.  Thanks for your help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial