Skip to main content
April 3, 2010
Question

Session State in new window

  • April 3, 2010
  • 2 replies
  • 536 views

Is there a way to keep session state when opening a new window this?

<a href="newpage.cfm" target="_new">

    This topic has been closed for replies.

    2 replies

    ilssac
    Inspiring
    April 4, 2010

    Session state depends on one or two tokens, depending on how session managements is configured in the Administrator.  By default the tokens are the cfid and cftoken, but if set up it can be one token, JSessionID that is sharable with JSP sessions.

    These tokens are normally passed back and forth in each request and response as cookies.  But they can also be passed as url tokens.  So you could maintain the session with this type of link.

    <a href="newpage.cfm?cfid=#session.cfid#&cftoken=#session.cftoken#"....>

    Or, if you are using the other token...

    <a href="newpage.cfm?jsessionid=#session.jsession.id#"...>

    But none of that should be required.  As the default cookie method should be passing these tokens automatically.  If they are not, you may want to investigate why.

    April 4, 2010

    Thanks a lot for your response. But I'm trying to figure out a way to debug this, i have done this before and it worked fine, not sure why it wouldn't be working now. Do you know if there are any known issues with sessions running coldfusion 9 on debian linux?

    April 3, 2010

    Also i'm not sure whats going on with session variables here, but i have them set to expire after 30 mins and i am testing this function out but it keeps dying saying that this parameter is not being passed.

    When i first get to this page and output the session var it works fine:

    <cfoutput>

         #session.dsn# (which equals "testDSN")

    </cfoutput>

    <cfif isDefined("form.fname")>

    <cfinvoke component="cfc.test" method="search" returnvariable="customers">

         <cfinvokeargument name="fname" value="#form.fname#">

         <cfinvokeargument name="dsn" value="#session.dsn#">

    </cfinvoke>

    <cfoutput>

         #customers.RecordCount#

    </cfoutput>

    <cfelse>

    <cfform action="#CGI.SCRIPT_NAME#" method="post">

    <cfinput type="text" name="fname"><br>

    <input type="submit" value="search">

    </cfform>

    ==============test.cfc===============

    <cfcomponent>
    <cffunction name="search" access="public" returntype="query">
         <cfargument name="fname" type="string" required="yes">
            <cfargument name="dsn" type="string" required="yes">

            <cftransaction>
       <cfquery name="lookup" datasource="#arguments.dsn#">
                 SELECT *
                    FROM tbl_users
                    WHERE fname LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fname#">
                </cfquery>
      </cftransaction>
           
            <cfreturn lookup>
    </cffunction>
       
    </cfcomponent>