-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forward cookies from login page form to resource page #438
Comments
Thanks for the detailed description! Could you try if it works with |
Unfortunately I see the same behaviour when changing submit_once to false. However I've found an alternative solution to save the value of the cookies in a sensor. I'll explain how just in case it can help someone else. In configuration.yaml I have added the following lines:
I have created a sensor with the Home Assistant (FILE integration) that will be reading the content from form_page_response_cookies.txt file. File path: /config/multiscrape/habidat/form_page_response_cookies.txt
This way, I have the cookie value saved in a sensor that I can use for another call to multiscraper using the option:
If I want to store cookies that are more than 255 characters in lengh (Like for example Authorization cookies) what I did is create two file sensors for each cookie and storing the first 240 characters in one sensor (By changing the template to @danieldotnl if I can make a feature request: I think being able to directly save the value of the cookies in a sensor with multiscraper would be wonderful and much simpler. Thank you! |
Hello, I'm reaching the same issue today. Let me know if you need any more precisions. In my case, I have a 302 redirection just after login, and it seems that the phpsessid is lost because of this, I can't find it in the log_reponse folder files |
Cookies are a snake pit :( |
Indeed, seems similar issue but I didn't catch everything yet. How are cookies set in multiscrape ? |
Few progress on my case
What would be useful in my case
One interesting thing to note is that PHPSESSID is sent even if I'm not logged in on my test case. Maybe that's because a login form is displayed on the top of each page. |
Version of the custom_component
8.0.2
Configuration
Describe the bug
First of all I want to thank the developer for this amazing custom component.
Cookies set when loading the form page (form_page_response_cookies) and also set when submitting the form (form_submit_request_cookies) are not sent when requesting the resource page (page_request_cookies).
The issue I'm having is that the server sets a cookie with PHPSESSID when loading the form. But this cookie is not sent when loading the resource page, so it returns the login page again.
Everything works ok If I manually set the cookie via the headers option, but it only lasts a few minutes until the session expires.
Is there any way to retrieve and store the cookies from the form page and send them to the resource page? I've tried reading all the issues related to cookies (#319 , #407, #327) but I couldn't figure out what I'm doing wrong.
Debug log
form_page_response_cookies.txt
<Cookies[<Cookie PHPSESSID=e3ffadacc4d2c58edf71c5add71a96## for plataforma.habidat.es />]>
form_submit_request_cookies.txt
<Cookies[<Cookie PHPSESSID=e3ffadacc4d2c58edf71c5add71a96## for plataforma.habidat.es />]>
form_submit_response_cookies.txt
<Cookies[]>
page_request_cookies.txt
<Cookies[]>
page_response_cookies.txt
<Cookies[]>
The text was updated successfully, but these errors were encountered: