I wrote a program to login to a website and do some automatic stuff (by making HTTP requests).
Most of these automatic stuff requires the program/session is in logged-in state (if the cookie expires, the program/session can not be considered in logged-in state), so I am implementing a isLoggedIn function to test it.
My current approach to get a page only available after login, but this requires a HTTP request and the transfer of a web page, so it is not very fast, what are other possible solutions?
Any lead will be appreciated!
Thank you very much!
As you mentioned yourself, the logged-in state is most of the time determined by validity of specific cookie. You can check if the cookie is still valid by comparing it's expiry time with the current time. Alternatively you can make HEAD request which allows you to get cookies (and other headers) without the need to download page body. However you have to check if the site handles HEAD requests for this to work.
What is the fastest way to test whether logged in or not when use python to login to a website?