Professional Web Applications Themes

kill session on browser close - Coldfusion - Advanced Techniques

nicorawa wrote:  Put this in your Application.cfm: <cfif IsDefined("cookie.cfid")> <cflock scope="session" type="readonly" timeout="5"> <cfcookie name="cfid" value="#session.cfid#"> <cfcookie name="cftoken" value="#session.cftoken#"> </cflock> </cfif> -- <mack />...

  1. #1

    Default Re: kill session on browser close

    nicorawa wrote: 

    Put this in your Application.cfm:

    <cfif IsDefined("cookie.cfid")>
    <cflock scope="session" type="readonly" timeout="5">
    <cfcookie name="cfid" value="#session.cfid#">
    <cfcookie name="cftoken" value="#session.cftoken#">
    </cflock>
    </cfif>

    --
    <mack />


    Neculai Guest

  2. #2

    Default Re: kill session on browser close

    There is no sure way to kill a session when your browser closes. You could
    try something like a body.unload that opens another page that processes a
    coldfusion template that will delete the session structure. Popup Blockers
    very well may kill that process though.

    --
    Thanks,
    ~ blackops ~


    Camps for Troubled Teens
    http://www.brat-camps.com
    Brat Camps - Free Search; Results Fast

    Teen and Drug
    http://www.teenanddrug.com
    Teen and Drug - Resources for Parents
    "nicorawa" <com> wrote in message
    news:dih0lg$7da$macromedia.com...
    What is the best way to kill session scoped variables on browser close?

    Is this possible in CF 5.0?

    I'd rather not use client scopes, but can if need be.

    Thanks,


    Brat Guest

  3. #3

    Default Re: kill session on browser close

    >... What is the best way to kill session scoped variables on browser close?
    Upgrade to MX and use J2EE session management

    BKBK Guest

  4. #4

    Default Re: kill session on browser close

    There is no way to kill session scoped variables on browser close.

    When you use J2EE session tracking, all it does is the same thing as the code
    that Mack provided, which is set the session tracking information as transient
    cookies that get deleted when the browser is closed.

    -however-

    Just because the browser closes, and the method used to access the session
    where the variables are stored is gone, the session variables are still on the
    server. They will be there until the session times out.

    A minor difference, but a difference.

    Kronin555 Guest

  5. #5

    Default Re: kill session on browser close

    >... There is no way to kill session scoped variables on browser close.

    MX7 livedocs:
    "If you use J2EE session management, ColdFusion MX ends the session and
    deletes all Session scope variables when the user closes the browser, or if the
    client is inactive for the session time-out period."

    BKBK Guest

  6. #6

    Default Re: kill session on browser close

    BKBK,

    I'm well aware of what Macromedia says re: J2EE sessions. I'm also well aware
    of the underlying methodology with which that is accomplished.

    Trust me, when you close a browser window, nothing is sent to the coldfusion
    server to tell it: "Delete session variables now". Those session variables
    exist until timeout, unless you explicitly logged out and deleted them before
    closing your browser.

    All J2EE session tracking does is place a transient cookie on the user's
    browser (if cookies are enabled), and if cookies aren't enabled, it uses
    jsessionid in the URL. There is nothing magic in J2EE session tracking that
    allows a browser to "phone-home" before closing, which is what would be
    necessary to delete session vars on browser close.

    Kronin555 Guest

  7. #7

    Default Re: kill session on browser close

    BKBK,

    I'm well aware of what Macromedia says re: J2EE sessions. I'm also well aware
    of the underlying methodology with which that is accomplished.

    Trust me, when you close a browser window, nothing is sent to the coldfusion
    server to tell it: "Delete session variables now". Those session variables
    exist until timeout, unless you explicitly logged out and deleted them before
    closing your browser.

    All J2EE session tracking does is place a transient cookie on the user's
    browser (if cookies are enabled), and if cookies aren't enabled, it uses
    jsessionid in the URL. There is nothing magic in J2EE session tracking that
    allows a browser to "phone-home" before closing, which is what would be
    necessary to delete session vars on browser close.

    Confucius him say one recognize size of cat by trace paws.
    I'll take your word for it.



    BKBK Guest

  8. #8

    Default Re: kill session on browser close

    You can't delete session variables on browser close, but you can reset
    them when you open it again.

    <CFIF IsDefined("Cookie.CFID") AND IsDefined("Cookie.CFTOKEN")>
    <CFSET VARIABLES.cfid_local = Cookie.CFID>
    <CFSET VARIABLES.cftoken_local = Cookie.CFTOKEN>
    <CFCOOKIE NAME="CFID" VALUE="#VARIABLES.cfid_local#">
    <CFCOOKIE NAME="CFTOKEN" VALUE="#VARIABLES.cftoken_local#">
    </CFIF>

    jgray7@gmail.com Guest

Similar Threads

  1. Kill one session variable
    By umuayo in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: April 5th, 09:04 AM
  2. on browser close kill session variables with jsessionidsystem
    By rogerjud in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: September 6th, 09:41 PM
  3. SESSION and browser close
    By grease in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: March 31st, 11:08 PM
  4. Kill session / force sign out
    By Mohammad Samara in forum ASP.NET Security
    Replies: 1
    Last Post: February 1st, 07:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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