2
votes

I have a login function that authorizes against a remote database over xml webservice. Upon successful login, I set a bunch of session variables for the logged-in user that follow them around the site (members only content, etc). This all works fine.

We are setting up a store and would like to have access to the session variables, for member pricing, pre-filling forms and so on. For now, the link to the store is available only after a member logs in. I am including the url token in the link, like so:

https://mysite.com/store/index.cfm?<cfoutput>#session.urltoken#</cfoutput>

CFdumping the session on the store page shows the same cfid, cftoken and jsessionid as from the login page, so I think the session is being correctly maintained -- but none of my session variables show up in the dump, and if I try to reference them I get the "is undefined in session" error.

This happens whether I go from login to store via http > http, https > https, or other combination. It's all on the same server. I would appreciate any help in resolving this, or if anybody has a better suggestion on how to accomplish our goal, I would really appreciate that too! Again, all I want to do is have the store recognize a logged-in member as such, when they first arrive at the store home page. Thanks a lot!

2
Have you confirmed that the full URL is the same (ie, mysite.com or www.mysite.com on both sides)? Otherwise, your code should work. - Billy Cravens
Are you staying within the same application? In other words, is application.applicationname the same in both cases? - ale
Hi Billy thanks, the URL is the same -- they are both part of the same site, ie getting past mysite.com/login.cfm will set the session vars and provide a link to mysite.com/store/index.cfm. Al, I am checking on application settings now... thanks! - daltec
I don't understand how the session IDs are being maintained across two applications. Each application should be setting its own cookie. Is it possible that something is clearing the session values, but preserving the cfid and cftoken values? (a proper logout) - J.T.
Could you please post your <cfapplication> tag? - Jake Feasel

2 Answers

1
votes

Both applications need to have the same name

If they have different names, then all application session variables are specific to that application.

so in application.cfm make sure name is set if you have any application.cfc that might be set using this.name in the constructor.

-1
votes

You can use server scope.

<cfset server.sharedSession[session.urlToken]=session>

To copy into a servers session:

<cfloop collection='#server.sharedSession['#url.urlToken#']#" index="i">
    <cfset session[i]=servers.sharedSession['#url.urlToken#'][i]>
</cfloop>

You could just copy the entire session, but looping allows you preserve values that aren't in the source session.