title: Selenium Python return login page after login success
body: <p>I try to scrape content from a website, with login code and otp code after login.
  Without using selenium, login and using page is ok. However, when I login by selenium and try to access a page it return login page again</p>
  <p>This is my code</p>
  <pre><code>options = webdriver.ChromeOptions() 
  #options.add_argument(&quot;--headless&quot;) # Runs Chrome in headless mode.
  options.add_argument('--no-sandbox') # Bypass OS security model
  options.add_argument('--disable-gpu')  # applicable to windows os only
  options.add_argument('disable-infobars')
  options.add_argument(&quot;--disable-extensions&quot;)
  options.add_argument(&quot;AppData\\Local\\Google\\Chrome\\User Data\\Defaul&quot;) #Path to your chrome profile
  driver = webdriver.Chrome(executable_path=&quot;\\chromedriver.exe&quot;, chrome_options=options)
  #driver=webdriver.Chrome()
  site=&quot;https:xxxxxx&quot;
  # call open browser function
  # Github credentials
  username = &quot;username&quot;
  
  password = &quot;password&quot;
  
  # head to github login page
  driver.get(site)
  # find username/email field and send the username itself to the input field
  driver.find_element_by_id(&quot;username&quot;).send_keys(username)
  time.sleep(20)
  # find password input field and insert password as well
  driver.find_element_by_id(&quot;password&quot;).send_keys(password)
  time.sleep(25)
  # click login button
  driver.find_element_by_id(&quot;btnLogin&quot;).click()
  otp=&quot;xxxxxx&quot;
  driver.find_element_by_id(&quot;otp&quot;).send_keys(otp)
  driver.find_element_by_xpath(&quot;/html/body/div/div/div/div/button[1]&quot;).click()
  </code></pre>
  <p>I save my session</p>
  <pre><code>s = requests.Session()
  # Set correct user agent
  selenium_user_agent = driver.execute_script(&quot;return navigator.userAgent;&quot;)
  s.headers.update({&quot;user-agent&quot;: selenium_user_agent})
  
  for cookie in driver.get_cookies():
      s.cookies.set(cookie['name'], cookie['value'], domain=cookie['domain'])
  </code></pre>
  <p>Then
  driver.get(&quot;https:mysite.com/page1&quot;)
  I return login page again</p>
  <p>Thanks for reading and helping me</p>