|
How to Access Cookies Set at the Client Side |
|
|
This tip shows the way to access the cookie information stored at the client side. To access the cookies information at the client side javax.servlet.http.cookies class is used.
The following code demonstrates this technique. It checks the existence of cookie ‘MyCookie’.
boolean Democookiefound = false;
Cookie[] cookies = request.getCookies();
for(int nIndex=0;nIndex < cookies.length;nIndex++){
if(cookies[nIndex].getName().equals(“MyCookie”)){
Democookiefound = true;
//desired cookie found, use it
}
}
if(Democookiefound == false) {
//cookies not found.
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.