Link to home
Start Free TrialLog in
Avatar of efkw
efkw

asked on

How can I handle cookies?

Hi all,

I want to save the member login information in Cookies. After user login, the information will be auto-add to client side PC, and show it in FORM next time. Once I put the GETCOOKIES statement, it generated error when enter the site said that: java.lang.NullPointerException.

But, when the user logined before, this error will not be show. I know that it is the error about the Cookie, but, how can I know the cookies has data or not before get it?

here is my code:

String cookiemail="";
Cookie cookies[]=request.getCookies();

for (int i=0;i<cookies.length;i++){
if(cookies[i].getName().equals("cookiemail")){
cookiemail=cookies[i].getValue();
break;
}
}

please help. Thanks!
ASKER CERTIFIED SOLUTION
Avatar of DidierD
DidierD
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial