user3648680
user3648680

Reputation: 51

Kill session variables when exiting browser in Coldfusion

I am looking for a solution on how to get ColdFusion to end the user's session when the users closes their browser.

In other words, when the user exits the browser I want them to re-login.

I have tried many solution to no avail.

Any help is appreciated.

Below is the latest code I got to insert in the application.cfm which would reset the session variable. Unfortunately it did not work.

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


    <CFPARAM NAME="session.allowin" DEFAULT="false" />
     <CFPARAM NAME="session.user_id" DEFAULT="0" />


    <cfif session.allowin neq "true">
        <cfif  ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">
        <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "login_process.cfm">
        <cfelse>
            <!--- this user is not logged in, alert user and redirect to the login.cfm page --->
            <script>
                alert("You must login to access this area!");
                self.location="login.cfm";
            </script>
        </cfif>
    </cfif>

Upvotes: 0

Views: 1443

Answers (1)

Related Questions