title: How to get cookie value from a WebDriver using selenium?
body: <p>/<em>I am using the following code to get the cookie value but I am only getting 1st and 2nd part.But not getting 3rd and 4th part(null as you can see).
  Please help me with this.I have attached the screenshot of the cookies i get manually</em>/
  <a href="https://i.stack.imgur.com/QzPz9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QzPz9.png" alt="enter image description here"></a></p>
  
  <pre><code> WebDriver driver;
          System.setProperty("webdriver.ie.driver",
                  "C:\\Users\\MR049860\\Documents\\Selenium\\IEDriverServer\\IEDriverServer.exe");
          driver = new InternetExplorerDriver();
          driver.get("https://www.example.com");
  
          // Input Email id and Password If you are already Register
          driver.findElement(By.name("j_username")).sendKeys("publisher");
          driver.findElement(By.name("j_password")).sendKeys("Passw0rd");
          WebDriverWait wait = new WebDriverWait(driver, 5);
          WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("BtnButton__")));
          // WebElement ele = driver.findElement(By.id("ctllogonBtnButton__"));
          element.sendKeys(Keys.ENTER);
          // create file named Cookies to store Login Information     
          File file = new File("madhu.data");                         
          try     
          {     
              // Delete old file if exists
              file.delete();      
              file.createNewFile();           
              FileWriter fileWrite = new FileWriter(file);                            
              BufferedWriter Bwrite = new BufferedWriter(fileWrite);                          
              // loop for getting the cookie information      
  
              // loop for getting the cookie information      
              for(Cookie ck : driver.manage().getCookies())                           
              {           
                  Bwrite.write((ck.getName()+";"+ck.getValue()+";"+ck.getDomain()+";"+ck.getPath()+";"+ck.getExpiry()+";"+ck.isSecure()));                                                                                                    
                  Bwrite.newLine();             
              }           
              Bwrite.close();         
              fileWrite.close();  
  
          }
          catch(Exception ex)                 
          {       
              ex.printStackTrace();           
          }
  </code></pre>
  
  <p>Output : - 
  ASPSESSIONIDSZQPRQCS;NFPFIAGDBMJNOMKPCPKESHDC;null;/;null;true</p>