Due to the way the servlet engine tracks sessions, there can be only one per request. That session can hold an essentially unlimited number of objects (not particularly practical.) If you need to hold lots of data per user consider using a database or writing your own session manager equivalent. Bill
You can. I cannot think of any reason why you would want to, but here's my half-baked idea of how to do it: 1) Create a subdomain with an alias, say "sub." 2) Use a wrapper class "MultipleDomainSession" so that multiple sessions can be added to this wrapper and that calling setAttribute on any session will cause 3) implement a request filter. In the filter, call MultipleDomainSession.getSession(hreq.getSession(true)). - If null, set the cookie. Give it a value of the session id. Call setDomain(".yourhost.com") on the cookie and add it to the response. - otherwise, if the value is not that of the sessionid, add a separator and the session id. You will then have a cookie that looks like: "MDSCookie=2354eddafcc08342345a88aecb-25a83ecd8aaf08344e235ccd4b" If you are using lots of subdomains, you'll have a very long cookie value. (You can translate the base of number to use Character.MAX_RADIX (base 36) instead of the session's hex (base 16). You can look up your wrapper with any sessionid in the MDSCookie. Calling getAttribute/setAttribute on your MultipleDomainSession instance will cause it to use its own Hashtable. You can implement HttpSessionBindingEvent for each session added to a MultipleDomainSession wrapper.
Discussion: When a request is made for "http://www.yourhost.com/path," a new session will be created. Adding the new session to a wrapper provides an object with access to all data in the object. [ December 02, 2002: Message edited by: Garrett Smith ] [ December 02, 2002: Message edited by: Garrett Smith ]
Author and all-around good cowpoke
Joined: Mar 22, 2000
ewww! That is really twisted!
Joined: Jun 27, 2002
You could probably do a much neater job if you were to first study the source code for HttpSession. Sun has considered session tracking a lot more than I have, and did so with knowledge, teamwork, and experience than I don't have.