Skip to main content
WolfShade
Legend
April 27, 2016
Question

Keep a value across different application names

  • April 27, 2016
  • 1 reply
  • 954 views

Hello, all,

I'm trying to find a way to keep something persistent across different application names without using the server scope (which could be lost upon reboot.)

Here's the situation.  I've got a very large site.  Many sections utilize the root application.cfc, but others have their own application.cfc with a unique name.

/dtr/application.cfc   <!--- app name = "dtr" --->

/dtr/index.cfm

/erc/index.cfm   <!--- uses root app.cfc --->

/mov/application.cfc   <!--- app name = "mov" --->

/mov/index.cfm

/suv/index.cfm   <!--- uses root app.cfc --->

/zyx/application.cfc   <!--- app name = "zyx" --->

/zyx/index.cfm

/root/application.cfc   <!--- app name = "ust" --->

/root/index.cfm

No matter which page is loaded, first, (could be bookmarked, or link sent in a message) I need to check to see if the user has seen a banner alert.  If not, display the alert and set a value for all future references.

I thought of session cookies, but when you get to a section with it's own app.cfc and the name changes, boom.. the previous set session value doesn't exist in this new session.

I thought of standard cookies, but I need the cookie to clear if/when the user closes the browser, so the banner will be viewed the next time the user visits.

I (obviously) don't want this alert loading on every page, every time.  That would be super-annoying. 

Any thoughts or suggestions on how to make this work?

V/r,

^_^

    This topic has been closed for replies.

    1 reply

    EddieLotter
    Inspiring
    April 27, 2016

    Session management is the bane of Web application development. It is very fragile and doesn't always represent the seat warmer on the other end of the connection.

    The Web server has no idea when the user closes the tab/window/browser, of which there can be several.

    You might have a hope if your users are authenticating. That way you can maintain a datetime value in a user table and only show the banner message after a certain timeout duration.

    Good luck.

    Cheers

    Eddie

    WolfShade
    WolfShadeAuthor
    Legend
    April 27, 2016

    Hi, EddieLotter, thanks for replying.

    If there were a way to write a cookie to the HD, but remove it when the browser closes (like a session cookie, but not as volatile), that could work.  It wouldn't be a session cookie, so it wouldn't be limited to just one application (based upon app name).  I've tried adding the domain name to it, but that still didn't fix the "different apps, different names" issue.

    The users are authenticating, but the timed idea would quickly draw the ire of either the users (if the time is too short) or the decision/policy makers (if the time is too long.)

    There has to be a way for the browser to keep a value across different app names (similar to SSO, but not SSO) that I'm just not seeing.

    V/r,

    ^_^

    BKBK
    Community Expert
    Community Expert
    April 27, 2016

    WolfShade wrote:

    If there were a way to write a cookie to the HD, but remove it when the browser closes (like a session cookie, but not as volatile), that could work. It wouldn't be a session cookie, so it wouldn't be limited to just one application (based upon app name).

    Then the session cookie is in fact what you need. That is, a cookie for which you define no expires attribute. Here the word "session" refers to the browser session, not to the Coldfusion session.

    So, with

    cookie.someVar = "someValue";

    you'll be on your way.