Skip to main content
Inspiring
May 29, 2009
Question

Replace session variables

  • May 29, 2009
  • 2 replies
  • 1099 views

Hello,

We have an application using session variables and we have some issues with that.

It's a something better that we can use instead of session variables?

Basically at the time of user login to our site we get all the info from the database and we use all these info alone the application.

Thanks

JFB

    This topic has been closed for replies.

    2 replies

    Inspiring
    June 2, 2009

    It is usually the case that when the user opens "another browser window or tab," all of these are owned by a single instance of the web-browser, present the same set of "cookies," and therefore effectively share the same state.  (Which is nice for me right now because I did not have to log on to the forum in every Firefox window that's looking at this forum right now.)

    This is pure-and-simply an issue of "how HTML works" vis-a-vis "your application's design."

    BKBK
    Adobe Expert
    June 3, 2009

    Client variables may replace session variables.

    ilssac
    Inspiring
    May 29, 2009

    What issues are you having with sessions?  What do you need the replacement to do better?

    Session is a very standard feature and one would usually not replace it without very specific reasons.

    jfb00Author
    Inspiring
    May 29, 2009

    Looks like the sessions values are getting mixed when user open another window and save the info.

    Some info still the same but some info change depending of the user activity. We use a lot cfc components and we store the value of some components in sessions also.

    Maybe I'm not using the session correctly??

    Thanks

    JFB

    ilssac
    Inspiring
    May 29, 2009

    Well it maybe a problem of your design, it maybe a problem of users and it maybe the inherently stateless nature of HTTP applications.

    To build a robust HTTP web application one must understand the nature of requests and their relationship to state data.  Each and every request is completely independent of any other request that came before it or will come after it.  To provide some semblance of "state", ColdFusion generates user ID values, usually cfid and cftoke OR jsessionid depending on the server configuration.  These values are normally passed to and from as cookie values but can be configured to be passed as url values.

    That is all that your applicaiton can know about the client.  That it previoulsy received these identifiers and it is returning them.  They maybe comming from the ame brower/tab a different tab in a browser or a completely different browser instance.  And obviously if a user opens two tabs to the same data and changes the data in tab 2, tab 1 is never going to display the changed data until it is refreshed.

    If you need more state in your Application you need something more then just a browser/client to server intermittent connection.  A prime candidate for this would be a Flex/Flash application that can maintain much more state between the server and client.  It is of course not the only choice available for this.

    Without going to this extent you just need to build your code to not get confused if a user opens another browser.  To that end you should only store data relevant to the individual user in session data.  If multiple users are accession shared data, that data should be in a shared scope such as the application scope or on rare occasions the server scope.

    This is a big topic of application design and there is much to learn about it.  I would suggest a lot of reading, study, questions, and thinking.