0% found this document useful (0 votes)
37 views2 pages

Cookies

Netscape first introduced cookies in one of its early versions of Netscape Navigator to allow web servers to send information to browsers that would later be returned to the server upon revisiting the website. Cookies are stored in the browser as key-value pairs. To add a cookie, developers create a Cookie object with a key and value and add it to the response using the addCookie method. To retrieve cookies, developers use the getCookies method on the HttpRequest object which returns a Cookie array containing all cookies for that site.

Uploaded by

suganthi31
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Cookies

Netscape first introduced cookies in one of its early versions of Netscape Navigator to allow web servers to send information to browsers that would later be returned to the server upon revisiting the website. Cookies are stored in the browser as key-value pairs. To add a cookie, developers create a Cookie object with a key and value and add it to the response using the addCookie method. To retrieve cookies, developers use the getCookies method on the HttpRequest object which returns a Cookie array containing all cookies for that site.

Uploaded by

suganthi31
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Netscape first introduced cookies in one of the companys first versions of Netscape Navigator.

Cookies: Cookies are information that a Web server sends to a browser and that the browser returns back to web server when visiting the same Web site later. Cookie can be saved in a browser as a key value pair To add a cookie in browser we need to create an object for cookie class and use a HttpResponse object to send the data to browser. To create cookie object: Cookie ck=new Cookie(key,value) To add cookie to browser response.addCookie(ck); // addCookie method takes cookie objects as argument

To get or retrieve the all the cookie present in the browser we need to use a HttpRequest object To get cookie: Cookie ck[]=request.getCookies();

To display cookie present in cookie array: for(int i=0;i<ck.length;i++) {String str=ck[i].getName(); String value=ck[i].getValue(); out.println("<b><br>Name of the Cookie :"+str); out.println("<b><br> Value of the cookie :"+value); }

You might also like