The conclusion of the following question was that rebuilding session token after switching from http to https is a good idea.
In ColdFusion do I need to reestablish session tokens after switch from http to https?
The question is, what is the most effective way to do so?
This is one of those easier-said-than-done things.
It has been a while since I have researched this, so please take this with the understanding that you may need to troubleshoot it.
For Java EE sessions I think it is a bit easier because you can call invalidate() on the session. But, unfortunately, that is only half of the battle. You really have several problems to solve. They are
Find some way to store any existing session data that you need (serialize and store)
Invalidate the old session (Possible with both Java EE and CF sessions but the way to do it with CF sessions is undocumented)
Expire the old cookies
Create a new session
Copy the data from the old session that you stored in step 1 into the new session
Set new cookies for the new session
This may not seem too tricky, the potentially hard part is doing it in one request, since normally a session is not created until a request is made and cookies are not set until a response is returned.
I think it is easiest using Java EE because you can call invalidate() on the old session, and get a new one by called getRequestContext().getSession() (I believe this is the case, and I believe it ONLY works with Java EE sessions).
I have contemplated how to do these things with CF Sessions and the only thing I can think is to have the code that is creatign a new session make a CFHTTP request to a page on the site so that a new session can be created. The CFHTTP response will have a new cookie in it, then you can expire the old cookies, and set the new using the tag.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With