Search code examples
coldfusioncoldfusion-9coldfusion-8coldfusion-10

Check if Session still exists


On the time of login, coldfusion server assigns me a CFID and a CFTOKEN. Later on using those CFID and CFTOKEN how can I check if my session still exists or not.

In other words I want a function that will take CFID and CFTOKEN and will tell if the session related to those CFID and CFTOKEN still exists or not.

Thanks


Solution

  • The easiest way to achieve this would be to set a flag in the session when your user logs in.

    for example

    <cfset session.loggedin = true />
    

    then when you want to check if the user still has a valid session you can do

    <cfparam name="session.loggedin" default="false" />
    <cfif NOT session.loggedin>
      <!--- do something here --->
    </cfif>