• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Tracking with cookies disabled.

 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the following how the session can be tracked using URL Rewriting method. I heard that URL Rewriting method is used when the cookies are disabled. But i don't know how to implement it for the following examples.
Is it URL Rewriting will be considered by the server automatically when the cookies are disabled or what?
Thanks & Regards,
M.S.Raman.

[ August 22, 2003: Message edited by: Carl Trusiak ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, in order for that to work correctly, you need to encodeURLs. Try this example

If you turn Cookies off in your browser, the link will change.
[ August 22, 2003: Message edited by: Carl Trusiak ]
[ August 22, 2003: Message edited by: Carl Trusiak ]
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to check out what the encodeURL method of HttpServletResponse does, here is what the API says:
encodeURL
public java.lang.String encodeURL(java.lang.String url)Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and let's use a non-deprecated method, shall we?

replace

session.putValue(String, String)

with

session.setAttribute(String, String)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!