'Headless chromedriver not using profile data

Headless chromedriver won't access stored session data. It works fine when running headed. I've enabled remote debugging, and its definitely not a resolution or screen size issue. I've tried every argument combination that I can find and it continues to act as if it wasn't given any user data path or profile. I though that perhaps Facebook was just the culprit and was recognizing the headless mode and disallowing the saved log in data, but that isn't the case. I tried with other less sophisticated websites and their data isn't getting accessed either.

options = webdriver.ChromeOptions()
options.add_argument(r'--headless')
options.add_argument(r'--remote-debugging-port=9222')
options.add_argument(r'--ignore-certificate-errors')
options.add_argument(r'--disable-extensions')
options.add_argument(r'--profile-directory=Profile 1')
options.add_argument(r'--user-data dir=C:/Users/User/Desktop/AmazonInvCheck/fbSession')
options.add_argument(r'--no-sandbox') 
options.add_argument(r'--disable-gpu')  

while True:
    try:
        driver = webdriver.Chrome("C:\\Users\\User\\Desktop\\AmazonInvCheck\\chromedriver.exe",options=options)
    break
    except Exception as e: 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source