In my login
servlet I make a
test if it is possible to set add a cookie on the users computer. Only if it is possible to add the cookie the user is allowed to login the system.
If I have turned on the cookie settings on my computer and I try to login, the I a�m rejected first time but second time I can login the system.
I use this code to test if the users computer has enabled cookie settings.
cookie = new Cookie("test" , "test" );
cookie.setMaxAge( 100 );
cookie.setPath ("/");
response.addCookie( cookie );
for ( int i = 0 ; i < cookies.length ; i++ ){
cookie = cookies[ i ];
c_name = cookie.getName();
if ( c_name.equals( sheme_test ) ) {
cookieSettings = true;
}
}
if ( cookieSettings ){
//LOGIN
}
else {
//LOGOUT
}
It seems that the problem is that the the program is to slowly with ading the cookie and because of that it can�t find the cookie first time but only second time.
What is the problem and how can I solve it?