Skip to main content
Inspiring
November 6, 2008
Question

Set SESSION.var via hyperlink?

  • November 6, 2008
  • 3 replies
  • 403 views
Right now I am using a simple SESSION.variable to manage site flow for example:

<cfif isDefined("form.lastName")>
<cfinclude template="results.cfm">
</cfif>

To make this work I am redirecting literally most query/customizations back to index.cfm

First are there any major concerns about such a strategy?

Secondly if to "save a step/cleanup code" is there a way to directly set the SESSION.var and redirect immediately to index.cfm rather than (my present route) of having a hyperlink to a .cfm page which <cfset SESSION.var = and then <cflocation url="'index.cfm" ?

    This topic has been closed for replies.

    3 replies

    November 10, 2008
    Use the onRequestStart method in the application.cfc for this.

    You can check if the session exists etc and do whatever you want if it doesn't - redirects etc.

    Mikey.
    BKBK
    Community Expert
    Community Expert
    November 8, 2008
    You shouldn't be doing this on a per-page basis. If you wish to use sessions to manage flow, then you should do so in just one place, namely, Application.cfm or Application.cfc.

    Inspiring
    November 6, 2008
    I don't believe that there are any concerns about using the index page.

    We use it like so...

    (SomePage.cfm)
    <a href="index.cfm?curpage=something">Link</a>


    (index.cfm)
    <cfswitch expression="#url.curpage#">
    <cfcase value="something">
    <cfset session.varName = "someValue">
    <cfinclude template="something.cfm">
    </cfcase>
    <cfcase value="somethingElse">
    <cfinclude template="somethingElse.cfm">
    </cfcase>
    <cfdefaultcase>
    <cfinclude template="defaultPage.cfm">
    </cfdefaultcase>
    </cfswitch>