how to accept or dismiss cookies in selenium code example

Example 1: how to handle cookies in selenium

There are several ways to handle cookies 
driver.manage().getCookies(); 		    // Return The List of all Cookies
driver.manage().getCookieNamed(arg0); //Return specific cookie according to name
driver.manage().addCookie(arg0); 	 //Create and add the cookie
driver.manage().deleteCookie(arg0);  // Delete specific cookie
driver.manage().deleteCookieNamed(arg0);// Delete specific cookie according Name
driver.manage().deleteAllCookies();   // Delete all cookies

Example 2: how to handle cookies in selenium

There are several ways to handle cookies 
driver.manage().getCookies(); 		    // Return The List of all Cookies
driver.manage().getCookieNamed(arg0); //Return specific cookie according to name
driver.manage().addCookie(arg0); 	 //Create and add the cookie
driver.manage().deleteCookie(arg0);  // Delete specific cookie
driver.manage().deleteCookieNamed(arg0);// Delete specific cookie according Name
driver.manage().deleteAllCookies();   // Delete all cookies