Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default logout button

    I have a login page that displays a name/pw submit button.
    Currently a user submits these values and, if validated a sessio variable is
    creaetd with user data and a welcome message is shown. Now I want to add a
    logout button that shows as long as the user is logged in.
    Here is my code:

    <!--- show the logout button --->
    <cfinclude template="../includes/logout.cfm">

    <cfif isDefined("SESSION.userData")>
    <cfoutput>Welcome #SESSION.userData.name#!<br><br>Last login:
    <br>#SESSION.userData.lastLogin#<br>
    </cfoutput>
    <br><br><br><br><br><br>
    <cfinclude template="../includes/projectListing.cfm">
    <cfabort>
    </cfif>

    The actual code for logout button is in <cfinclude
    template="../includes/logout.cfm">:
    <cfif isDefined("FORM.logout")>
    <cfapplication name="timeSheet" sessionmanagement="yes"
    sessiontimeout="#createTimeSpan(0,0,0,0)#">
    <cfelse>
    <!--- logout button vertonen bij aanroep --->
    <form action="<cfoutput>http://#CGI.SERVER_NAME#</cfoutput>"
    name="logout"
    method="post">
    <br><br><br>
    <table align="center">
    <tr>
    <td>
    <input type="submit" name="logout" value="Logout" class="button">
    </td>
    </tr>
    </table>
    </form>
    </cfif>

    What happens is that if the user is logged in succesfully, the logout button
    is shown. But when clicked, the same greeting message appears along with the
    logout button as if the session variables are not deleted at all...

    What do I do wrong here?

    lingo_user Guest

  2. Similar Questions and Discussions

    1. logout
      Howdy, I have a question regarding logout page. Scenario: A user use login fine, bookmarks a page and then use logout successfully. When user...
    2. Can't logout administrator
      I can't logoff the administrator. everytime I launch the administrator it automatically logs in. The log off button doesnot work. How can I log it...
    3. inactivity logout
      I have a Flex application that I would like it to logout (essentially call a function) when there is no activity for a given time. (No mouse...
    4. logout(without getting page using back button)
      hi i would like to implement a logout page which is very secure so that after logging out a user cannot use the back button for accessing the...
    5. after logout, how to retrieve an expired page if user click 'back' button?
      hi everyone, i've made a login and logout page, after user have logout, i want to retrieve an expired page if user click the 'back' button to...
  3. #2

    Default Re: logout button

    One way to log out of a session is to clear the session variables with this
    command: <CFSET STRUCTCLEAR(SESSION)>

    Another thing to look at is your application.cfm file. Every cfm file in your
    folder will run application.cfm first. Make sure you logout page does not
    conflict with the application page in terms of checking session status.

    -Paul


    dempster Guest

  4. #3

    Default Re: logout button

    I think I'm still making a wrong assumption - here's what happens
    chronologically:
    >user logs succesfully in;
    >session var is set;
    >logout button is included: the code <CFSET STRUCTCLEAR(SESSION.userData)> and
    a self submitting form with 'logout' submit button;
    >user is logged in, clicks 'Logout' button;
    >template calls itself, executes the included logout button code
    If I put
    session = #isDefined("SESSION.userData")#
    right below this line it says
    session = YES.
    It should say session = NO since the structClear is executed.

    Btw, this also happens with
    <cfapplication
    sessionamagemanent="yes"
    sessiontimeOut="createTimeSpan(0,0,0,0)">

    Why does
    <CFSET STRUCTCLEAR(SESSION.userData)>
    session = #isDefined("SESSION.userData")#
    give me session = YES????

    lingo_user Guest

  5. #4

    Default Re: logout button

    Because StructClear doesn't delete the structure you're passing it, it just
    clears it. Therefore, SESSION.userdata is still defined, it's just empty.

    Change your call to:
    <cfset structdelete(SESSION,"userData")>

    Kronin555 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139