Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Logout Syntax Error

Guest
May 26, 2009 May 26, 2009

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;

Variable SESSION is undefined.

Does anyone know what I'm doing wrong?

Thanks in advance for the help.

5.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , May 26, 2009 May 26, 2009

There lies your problem:

http://livedocs.adobe.com/coldfusion/8/sharedVars_11.html

Translate
Guru ,
May 26, 2009 May 26, 2009

How do you create the session variable?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 26, 2009 May 26, 2009

<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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 26, 2009 May 26, 2009

Are you using an Application.cfc? Are you sure your session variables are not being timed out?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 26, 2009 May 26, 2009

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:

Variable SESSION is undefined.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 26, 2009 May 26, 2009
LATEST

There lies your problem:

http://livedocs.adobe.com/coldfusion/8/sharedVars_11.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources