Copy link to clipboard
Copied
Hi,
I working on a website with a login and logout set up. I have my login page working fine but I'm having an issue with the logout page. I have it set up so once I log in a "sign off" link appears, taking the user to the logout page. This is my logout.cfm code:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<cfset tmp=StructDelete(session, "username")>
<cflocation url="/login.cfm?lo" addtoken="no">
</body>
</html>
Whenever I run this page, I get this error message;
Does anyone know what I'm doing wrong?
Thanks in advance for the help.
There lies your problem:
http://livedocs.adobe.com/coldfusion/8/sharedVars_11.html
Copy link to clipboard
Copied
How do you create the session variable?
Copy link to clipboard
Copied
<cfset session.username='#checklogin.username#'>
Welcome <cfoutput>#session.username#</cfoutput> | <a href="logout.cfm">Sign Out</a>
<cfquery name="updatelogin" datasource="mydata">
update login
set lastvisit=#now()#, visits = visits + 1
where username='#session.username#'
</cfquery>
Copy link to clipboard
Copied
Are you using an Application.cfc? Are you sure your session variables are not being timed out?
Copy link to clipboard
Copied
No, I'm not using Application.cfc and I doubt its timing out so soon.
Login.cfm code:
<!--- Checking the login --->
<cfif isdefined ("form.username")>
<cfset good=1>
<cfquery name="checklogin" datasource="mydata">
select username,pw
from login
where username='#form.username#' and pw='#form.pw#'
</cfquery>
<!--- Set a session and updating visitors count --->
<cfif checklogin.recordcount is 1 and Compare(form.pw,checklogin.pw) Is 0>
<cfset session.username='#checklogin.username#'>
<cfquery name="updatelogin" datasource="mydata">
update login
set lastvisit=#now()#, visits = visits + 1
where username='#session.username#'
</cfquery>
<cfelse>
Incorrect login.
</cfif>
</cfif>
Logout.cfm code:
<cfset tmp=StructDelete(session, "username")>
<cflocation url="/login.cfm?lo" addtoken="no">
Error Message:
Copy link to clipboard
Copied
There lies your problem:
http://livedocs.adobe.com/coldfusion/8/sharedVars_11.html