Skip to main content
Participant
August 9, 2017
Question

J2EE setdomaincookies not working for JSESSIONID

  • August 9, 2017
  • 3 replies
  • 1299 views

i need to maintain session data between sub domains

you can do this easy by setting:

this.setdomaincookies="yes"

works perfectly because the cfid and cftoken cookies domain is set to ".domain.com" instead of "whatever.domain.com"

here is the problem. we are using J2EE sessions.

so the cookie that we need to have its sub domain blank is the JSESSIONID

this cookie is not set to ".domain.com" it remains "whatever.domain.com"

if i try to manually create the cookies by setting setclientcookies to false a very odd thing occurs. when i set the value to session.sessionid, the resulting value is set to for example: " F29D7D74818F64478776A879964C7E05%2Ecfusion", see how it has replaced the "dot" with "%2E"

i think this causes the brains to mark it as an invalid cookie so it creates another one, which then has its own valid value but does not work for us because its now its own session.

i read some stuff about editing the jrun-web.xml to fix this one million years ago but i cant find that file on cf2016.

This topic has been closed for replies.

3 replies

Participant
August 9, 2017

ok i think i may have it worked out

this is still a bug and should not be happening

but the workaround is this

setclientcookies = no

then add this

<cffunction name="onSessionStart" returnType="void" output="false">

<cfcookie name="JSESSIONID" value="#session.sessionid#" domain=".yourdomain.com" httponly = "yes" encodeValue="false">

</cffunction>

then do your regular onrequeststart stuff

maybe this will save some suicides out there.

Carl Von Stetten
Legend
August 13, 2017

Can you file a bug report about this behavior at Tracker ?  Please include minimal code required to demonstrate/reproduce the problem.

-Carl V.

Participant
August 9, 2017

as soon as i posted this i found out how to fix my "dot" problem

encodeValue="false" in the cfcookie.

but my problem is still here! the sub domain sets its own JSESSIONID cookie, and ignores the perfectly valid one already set

Participant
August 9, 2017

and i forgot to give you system specs:

Server Product ColdFusion 2016
Version 2016.0.03.301771 

Java Version

1.8.0_112  

windows 7

IIS 7.5