How to read client side cookies from a servlet

It is easy to read the cookies from a servlet.
Cookies[] getCookies() returns an array of Cookie objects.

// Check for cookies
Cookie[] cookies = request.getCookies();

// Check to see if any cookies exists
if (cookies != null)
{
for (int i =0; i< cookies.length; i++)
{
Cookie aCookie = cookies[i];
System.out.println (Name : + Cookie.getName());
System.out.println (Value:  + Cookie.getValue());
}
}

Share your Love

Technorati Tags:

This entry was posted in Blogging, CGI and Perl hosting, cPanel Help, Dedicated Server Hosting, Email Hosting, Internet Security, Linux Reseller hosting, Linux Web Hosting, Managed Dedicated Server, MySQL Hosting and issues, Php Web Hosting, Plesk Web Hosting, Semi-Dedicated Hosting, UK Datacenter and Network, UK Domain name registration, UK Reseller Webhosting, UK Web Hosting, Uncategorized, Web Design, Windows Reseller Hosting, Windows Web Hosting and tagged . Bookmark the permalink.

Leave a Reply