How to get JSESSIONID value on the first request? I spend four days on internet googling without resolving the problem Any help will be appreciated Thank you
Asked
Active
Viewed 449 times
0
-
1Please include your code. – Jonathan Rys May 16 '18 at 15:41
-
1I don't understand your question. The jsessionid will be created by the server on the first request. – Miguel-F May 16 '18 at 15:53
-
1Enable `jsession` from CFAdmin. Then try dumping cookie scope. – rrk May 16 '18 at 15:58
-
Thank you Miguel-F and RRK, I apologize for not reply sooner Jsession is enabled There is no problem with session creation, but I can’t read it on the first request, I see it only on the second request (reading it from cookie) Suppose that I want to store JSESSIONID value on db My code is :
#Cookie.JSESSIONID# -
What about session? Or in CGI scope? – rrk May 16 '18 at 16:58
-
same thing in CGI, the first request when Jsession is expired i get nothing, the seconde i got it – Sidahmed Mohamed May 16 '18 at 17:02
-
1I read from other discussion on stackoverflow this note: “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.” – Sidahmed Mohamed May 16 '18 at 17:05
-
This may be an [XY Problem](https://en.wikipedia.org/wiki/XY_problem). What are you actually trying to do? Why are you trying to use the jsessionid directly? The JVM is built to manage the session for you. You should not need direct access to the jsessionid. – Miguel-F May 16 '18 at 17:48
-
Thank you Miguel-F , I want to track user session, I know there is solution like GA, but I want personalize solution for specific pages campaign, so it’s better to have jsessionid for the first request stored to count session number and avrge time per session, …, instead of start from the second request if there is it – Sidahmed Mohamed May 16 '18 at 18:03
-
You don't need to mess with jsessionid to do that. This is my point. Just set a `session` variable and use that. Let the system handle it for you. In your Application.cfc, in the OnSessionStart method, set a session variable like `session.started = Now()`. That will tell you when the user's session was started. Then, if you want, you can do something in the OnSessionEnd method as well. Note that the session is dead at this point but you can still update a database column or some such. – Miguel-F May 16 '18 at 19:39
-
1[Configuring and using session variables](https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/using-persistent-data-and-locking/configuring-and-using-session-variables.html) – Miguel-F May 16 '18 at 19:39