• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookies

 
nagaraj reddy
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1....If you won't set any value to Cookie through setMaxAge(), then what will bethe return value of getMaxAge() of that Cookie ??


2... If you want to allow a cookie to live even though the browser closed or session expaired, then what to do ???
 
Pawan Ramchandani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet sends cookies to the browser by using the HttpServletResponse.addC00kie(javax.servlet.http.C00kie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limt c00kie size to 4 KB each.



Ans1:- getMaxAge()
Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.

Ans2:- setMaxAge(int expiry)
Sets the maximum age of the cookie in seconds.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic