How To Read Cookies Not Set By Flask
Solution 1:
When a cookie is created its domain is set. You need to ensure that the domain is set so that both sites domain match the cookie domain. For example example.com
will allow the cookies to be viewed by both sites or put another way they will be set along with the request to both servers.
The wordpress login can be integrated with Flask. You will need to extract the session id/cookie contents and then make a request to the wordpress site.
Flask Code:
request.cookies.get('username') # get single cookie
request.cookies # get all as dict
This requests check if the session is valid and returns the user credentials. If it succeeds - meaning the user can be automatically logged in - you then invoke cookies
Note: You will have to synchronize the sessions manually. When a session is created on the api side it will continue to exist until it expires or you manually call logout. Also if you log out of the wordpress side the flask session will continue to exist
More info on cookies
Post a Comment for "How To Read Cookies Not Set By Flask"