• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

knowing the clients supports cookies or not.

 
lokesh reddy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me, how can i know whether the client supports cookies or not not before instantiating a session.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lokesh,
How are things at WebVeda. Any how with respect to your query i think that you have to send a cookie to the client and then invoke another servlet which tries to retrieve the cookie. If the cookie is retreived by this servlet then cookies work else they don't. I will check up further if you really need it.
check out things here http://www.jguru.com/jguru/faq/view.jsp?EID=152
Regds
Rahul P. Mahindrakar
[This message has been edited by Rahul Mahindrakar (edited January 24, 2001).]
 
lokesh reddy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rahul sir,
I have done the same thing, but is there any way without doing all these things.
I have done in another way as follows.
HttpSession session=req.getSession(true);
if(req.isRequestedSessionIdFromCookie())
{
out.println("Cookies accepted");
}
else
{
out.println("Cookies rejected");
}
but i dint want to instantiate the HttpSession also.
I hope u can find a solution for this.
Bye.
With regards.
Loke.

[This message has been edited by lokesh reddy (edited January 24, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4489
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why cant you just do this?
private Cookie[] cookies = request.getCookies();
if (cookies != null) {
 
Balamurugan Kandasamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Randall,
This again would return array of cookies which are already stored on the client side. But say this is the first time my server has been accessed by the client then whats the solution as this method would return null though Cookies may be supported.
Hope i am right in my question.
Thanks
MKBala.
 
Balamurugan Kandasamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Randall,
This again would return array of cookies which are already stored on the client side. But say this is the first time my server has been accessed by the client then whats the solution as this method would return null though Cookies may be supported.
Hope i am right in my question.
Thanks
MKBala.
 
Balamurugan Kandasamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Would HttpSessions method
public boolean isNew()
useful to determine if the client supports cookie or not. Pls clarify...
Thanks
MKBala.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic