title: Python use same browser session and use cookies
body: <p>I'm running a simple scrape code to scrape a few lines from a website. The problem is that Python always opens a new Chrome window and logs in again every time I run the bot.</p>
  <p>So, I read online and created a Chrome profile. Now it opens the Chrome profile, but it still asks me to log in to the website. I guess I need to save cookies. I tried some YouTube tutorials, but I couldn't figure out how to save the cookies. I'm a complete noob, so can anyone explain to me how to do so?</p>
  <p>This is my code:</p>
  <pre><code>    ##First login and cookie save
  
           options = Options() 
  service = Service(&quot;C:\\Program Files (x86)\\chromedriver.exe&quot;)
  options.add_argument(&quot;user-data-dir=C:\\Users\\parko\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2&quot;)
  driver = webdriver.Chrome(service=service, options=options)
  options.add_argument(&quot;user-data-dir=C:\\Users\\parko\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2&quot;)
  driver.get(&quot;https://exmaplewebsitelogin.com&quot;)
      pickle.dump( driver.get_cookies() , open(&quot;cookies.pkl&quot;,&quot;wb&quot;))
  
  search = driver.find_element(By.NAME, 'fm-login-id')
  search.send_keys(&quot;example@gmail.com&quot;)
  search.send_keys(Keys.RETURN)
  
  time.sleep(3)
  search = driver.find_element(By.NAME, 'fm-login-password')
  search.send_keys(&quot;exmaplepassword!&quot;)
  search.send_keys(Keys.RETURN)
  
  time.sleep(3)
  
  search = driver.find_element(By.CLASS_NAME, 'fm-button')
  search.send_keys(Keys.RETURN)
  time.sleep(15)
  
  time.sleep(3)
  driver.quit()
  
  ## visiting the website after cookie saved
  options = Options() 
  service = Service(&quot;C:\\Program Files (x86)\\chromedriver.exe&quot;)
  options.add_argument(&quot;user-data-dir=C:\\Users\\parko\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2&quot;)
  driver = webdriver.Chrome(service=service, options=options)
      driver.get(&quot;https://exmaplewebsitelogin.com&quot;)
  cookies = pickle.load(open(&quot;cookies.pkl&quot;, &quot;rb&quot;))
  for cookie in cookies:
      driver.add_cookie(cookie)
  </code></pre>
  <p>As I mentioned before, it doesn't work. the Chrome profile is not saving the cookies  (user-data-dir=C..) and the cookies save I tried to do doesn't work either so it requires me to login again and again.
  Please help :)</p>