Reputation:
I created the cookies using JavaScript, the page is then reloaded and I retrieve the cookies with Python, but the only cookie that is retrieved is the session cookie.
Adding Cookie:
function changeFeatures() {
document.cookie = "byteName=" + document.getElementById("byteName").value+"; path=/";
document.cookie = "byteDescription=" + document.getElementById("byteDescription").value+"; path=/";
document.cookie = "byteType=" + document.getElementById("byteType").value+"; path=/";
document.cookie = "byteEndian=" + document.getElementById("byteEndian").value+"; path=/";
document.cookie = "byteParent=" + document.getElementById("byteParent").value+"; path=/";
document.cookie = "byteOffset=" + document.getElementById("byteOffset").value+"; path=/";
document.cookie = "byteLength=" + document.getElementById("byteLength").value+"; path=/";
location.reload();
}
Retrieving Cookie:
import requests
r = requests.get('http://localhost:5000/)
print(r)
c = r.cookies
print(c)
i = c.items()
print(i)
r prints:
Response [200]
c prints:
RequestsCookieJar[]
i prints:
[('session', 'eyJfZmxhc2hlcyI6W3siIHQiOlsibWVzc2FnZSIsIlBsZWFzZSBsb2cgaW4gdG8gYWNjZXNzIHRoaXMgcGFnZS4iXX1dLCJfZnJlc2giOmZhbHNlfQ.XJEbzA.2QOTc9iPNBD_RSEVgAdnvR36chE')]
Upvotes: 1
Views: 371
Reputation:
I figured it out. I was supposed to use request.cookie
in python to retrieve the cookie since I'm using Flask.
Upvotes: 1