Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python how to get the domain of a cookie

Tags:

python

I want to get the domain of the cookie from the HTTP response. Code is:

cookie = Cookie.SimpleCookie() 
cookie.load(cookie_string) 
print 'cookie = ', cookie 

this shows the cookie as

cookie= Set-Cookie: Cycle=MA==|MA==|MA==; Domain=.abc.xyz.net; expires=Tue, 05-Oct-2021 04:15:18 GMT; Path=/

I want to extract the domain from the above result.

I am trying

print cookie['Domain']
print cookie['Domain'].value
print cookie['Cycle']['Domain'].value

None of these work.

Thanks

like image 818
SUM Avatar asked Nov 04 '22 13:11

SUM


1 Answers

try:

cookie['Cycle']['domain']    # lowercase domain !
like image 167
Michał Šrajer Avatar answered Nov 14 '22 23:11

Michał Šrajer