• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I save and restore Session?

Explorer ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

Is it possible to have a user leave the site for a period of time, say 2 or 3 days, and when they come back, restore their last session and all the session variables? I have an idea of building a database and writing them all to the db on each page load with the last visited page, and then resetting from that on their next visit, but is there an easier way through Cold Fusion that I'm not aware of? Any assistance is apprecaited.
TOPICS
Advanced techniques

Views

753

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

Store a unique ID for the user in a cookie, and store the data relating to
the user in the DB, keyed on that unique ID. When a user shows up with
such a cookie set, load the data from the DB, and bung it back in their new
session.

I'm using "bung" in it's technical sense, here ;-)

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2008 Feb 01, 2008

Copy link to clipboard

Copied

Yes, that's what I had planned on doing, but there are 847 session variables to track and I'm looking for an efficient way to store & retrieve them. I see the session structure, is it possible to store that in a blob field?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 01, 2008 Feb 01, 2008

Copy link to clipboard

Copied

> Yes, that's what I had planned on doing, but there are 847 session variables to
> track and I'm looking for an efficient way to store & retrieve them. I see the
> session structure, is it possible to store that in a blob field?

Yep, just serialise the whols truct with CFWDDX and chuck it in a clob (not
blob) field.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_u-z_2.html

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2008 Jan 31, 2008

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 01, 2008 Feb 01, 2008

Copy link to clipboard

Copied

I had a client that had hundreds of session variables scattered in hundreds of CF pages. There was very little CFLOCKing, and consequently the apps were quite unstable in a loaded environment.

What I finally did was to copy the session scope variables to ses.request scope variables of the same name, then did a global replace of session. with ses.request. In OnRequestEnd.cfm, and immediately before all CFLOCATIONs, I copied ths ses.request scope back to session scope (locked, of course). There was no measurable performance hit, and the apps were rock solid.

Perhaps you could copy your client variables to session scope; then back again in OnRequestEnd.cfm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 04, 2008 Feb 04, 2008

Copy link to clipboard

Copied

I have been able to use the wddx to deserialize and store the data in my database, what I'm trying to do now is read it from the datbase, and then reassign those session values to the client but I keep getting errors.

I used <cfwddx action="wddx2cfml" input="#getsession.appsession#" output="AppSession">

Then I try and set my session structure equal to the appsession but it retains the previous session data..

My question is how do I replace the current client info with the session data I pull from the databasae?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 05, 2008 Feb 05, 2008

Copy link to clipboard

Copied

LATEST
Okay, to answer my own question here:

My question is how do I replace the current client info with the session data I pull from the database?

You use StructAppend

#StructAppend(session, AppSession, True)#

Viva CF Docs! 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation