Skip to content

Cookie Validation Issue #259

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

Closed
emerladCoder opened this issue Mar 14, 2025 · 16 comments
Closed

Cookie Validation Issue #259

emerladCoder opened this issue Mar 14, 2025 · 16 comments
Labels
bug Something isn't working

Comments

@emerladCoder
Copy link

It appears that Patron has changed the domain for session_id cookie, so the validator is failing to find session_id and erroring. Session id is now using www.patreon.com on my end instead of .patreon.com like all the other cookies.

2025-03-14 15:25:40.1908 FATAL [PatreonDownloader.App.Program] Fatal error, application will be closed: UniversalDownloaderPlatform.Common.Exceptions.CookieValidationException: session_id cookie not found at PatreonDownloader.Implementation.PatreonCookieValidator.ValidateCookies(CookieContainer cookieContainer) in M:\Downloaders\PatreonDownloader\Dev\PatreonDownloader.Implementation\PatreonCookieValidator.cs:line 34 at UniversalDownloaderPlatform.Engine.UniversalDownloader.Download(String url, IUniversalDownloaderPlatformSettings settings) in M:\Downloaders\PatreonDownloader\Dev\submodules\UniversalDownloaderPlatform\UniversalDownloaderPlatform.Engine\UniversalDownloader.cs:line 181 at PatreonDownloader.App.Program.RunPatreonDownloader(CommandLineOptions commandLineOptions) in M:\Downloaders\PatreonDownloader\Dev\PatreonDownloader.App\Program.cs:line 128 at PatreonDownloader.App.Program.Main(String[] args) in M:\Downloaders\PatreonDownloader\Dev\PatreonDownloader.App\Program.cs:line 68

Here is a view of the SQLite db for my instance of Chrome that the downloader is managing.
Image

The fix (while maintaining the validation check), would be to just combine the cookies for the two domains before validating.

In PatreonDownloader.Implementation\PatreonCookieValidator.cs I just added the one line below to combine the two domains cookie sets before the validation check.

CookieCollection cookies = cookieContainer.GetCookies(new Uri("https://patreon.com"));
cookies.Add(cookieContainer.GetCookies(new Uri("https://www.patreon.com"))); // added this, combine the two domains cookies for validation checks

if (cookies["__cf_bm"] == null)
    throw new CookieValidationException("__cf_bm cookie not found");
if (cookies["session_id"] == null)
    throw new CookieValidationException("session_id cookie not found");
if (cookies["patreon_device_id"] == null)
    throw new CookieValidationException("patreon_device_id cookie not found");

Doing the above fixes the issue on my end and the downloader is working fine after that.

@horryruo
Copy link

Thank you very much, I found the code, but my computer does not have vscode installed, how can I compile it?

@emerladCoder
Copy link
Author

The Build Instructions are here.

I use Visual Studio 2022 for building, community edition should be sufficient.

@horryruo
Copy link

horryruo commented Mar 19, 2025

Thank you, I used the donet command line to build, Visual Studio is too big

@Stoneheach
Copy link

I have the same error but where can i put the code into? I don't have the file on my PC in the folder?

@CaptainKoons
Copy link

Thank you, I used the donet command line to build, Visual Studio is too big

Could you perhaps post a step-by-step explanation of exactly how you did this?
Unfortunately, I'm not that much of a programming pro...
Many thanks!

@AlexCSDev
Copy link
Owner

Will be fixed when I have time.

@AlexCSDev AlexCSDev added the bug Something isn't working label Mar 26, 2025
@AlexCSDev AlexCSDev pinned this issue Mar 26, 2025
@legendarysword2
Copy link

looks like once I figured out my issue I have the same issue

@FieryAced
Copy link

This is the earliest I've been to a bug 😅 cool fix though!

@VariableVixen
Copy link

#262 appears to include a fix for this as well, by changing line 29 to instead read

CookieCollection cookies = cookieContainer.GetAllCookies();

The filter implementation is inefficient (it uses a nested loop where a HashSet<> would work better) but if that's fixed (or considered acceptable) then merging that PR should also resolve this issue.

@EmperorHaro
Copy link

If you don't mind how do we add your code to the existing one?

@VariableVixen
Copy link

As has been commented already, the repository includes build instructions. You will need to clone the repository, make the one-line edit, and compile the project. If you don't understand how to do that, you are very unlikely to have the tools necessary, which will only complicate matters.

If you are able to make the edits yourself, it is strongly recommended that you do so, for the sake of security. If you are not able to make the edits yourself, you may instead download a fixed copy that I compiled for 64-bit windows and replace the original. The linked copy has only the change outlined here, and does not contain a settings.json file so it is safe to unzip to (and overwrite) your existing copy.

If you are not able to make the required change and recompile and you are not willing to use my pre-compiled version with the fix, please do not ask how to make the edit yourself. Teaching you how to clone and compile source code is well beyond the scope of a github issue. The developer knows what needs to be fixed and will get to it when they have the opportunity.

@CaptainKoons
Copy link

@PrincessRTFM your fixed copy works perfectly! Many thanks! ❤

@icedpingu
Copy link

If you are able to make the edits yourself, it is strongly recommended that you do so, for the sake of security. If you are not able to make the edits yourself, you may instead download a fixed copy that I compiled for 64-bit windows and replace the original. The linked copy has only the change outlined here, and does not contain a settings.json file so it is safe to unzip to (and overwrite) your existing copy.

Thank you so much!

@EmperorHaro
Copy link

Your link works, thank you so much! I think I understood the instructions and made the clone/edits myself.

@Toxic-Cookie
Copy link

I cloned the master repo with GH Desktop, set the current branch to the PR with the cookie fix, changed the build type from debug to release, built the app solution, went to the bin folder and then ran it without any errors throwing. Thanks!

@AlexCSDev
Copy link
Owner

Fixed in Release 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.