I'm using ColdFusion 10 and J2EE session variables. To log a user out (end a session) I'm using getPageContext().getSession().invalidate()
this works fine until I run my MXUnit tests and one of them tests the logout process. The session is invalidated and subsequent tests fail because there is not an active session. Is there a way to create a new session without reloading the page?
Asked
Active
Viewed 342 times
2

Matt Busche
- 14,216
- 5
- 36
- 61
-
Have you trued using `sessionInvalidate()`? It is new to ColdFusion 10 – Scott Stroz Nov 20 '13 at 20:19
-
@ScottStroz `sessionInvalidate()` doesn't invalidate J2EE session variables. – Matt Busche Nov 20 '13 at 20:21
-
2There is a note on the page that you referenced - _You cannot destroy the session and create a session on the same request, as creating a new session involves sending session cookies back._ – Miguel-F Nov 20 '13 at 20:32
-
@Miguel-F thanks, reading is hard. i'll update the test suite to run these last which should fix the issue. – Matt Busche Nov 20 '13 at 20:44
-
@MattBusche - sometimes you just need another set of eyes. Happens to me quite a bit... – Miguel-F Nov 20 '13 at 21:07
1 Answers
1
For better visibility from the comments
I don't think you can create a new session without sending/receiving data from the client. There is a note on the page that you referenced (at the bottom):
You cannot destroy the session and create a session on the same request, as creating a new session involves sending session cookies back.

Miguel-F
- 13,450
- 6
- 38
- 63