python selenium webdriver set cookie

Developer from somewhere

Problem: use provided cookies with selenium python bindings

Solution: found here:

from selenium import webdriver

driver = webdriver.PhantomJS()
driver.get('http://stackoverflow.com/')

cookies = driver.get_cookies()

driver.delete_all_cookies()

for cookie in cookies :
    driver.add_cookie({k: cookie[k] for k in ('name', 'value', 'domain', 'path', 'expiry')})