I'm trying to pass some custom variables like the user_id into my web application using the TAdvWebBrowser component. I want to do this by setting cookies manually in the request headers. Here's the code I'm using:
However, as soon as the NavigateWithData method is called, I get an Access Violation error:
Exception class $C0000005 with message 'access violation at 0x00d6dc4f: read of address 0x00000000' in Project2.exe.
Has anyone encountered this issue before? Am I using the NavigateWithData method correctly, or is there a better way to pass cookies to a site loaded with TAdvWebBrowser?
I recently discovered that as soon as I use AddCookie, only one cookie can be set successfully. When I try to add a second cookie like in the example below:
testcookie := NewCookie('username', 'username', 'localhost', '/', Now + 1);
testcookie2 := NewCookie('username2', 'testcookie2', 'localhost', '/', Now + 1);
WebBrowser.AddCookie(testcookie);
WebBrowser.AddCookie(testcookie2);
No cookie gets added at all.
What’s strange is that setting a single cookie works without any issues. However, for the sake of clean structure, I’d like to pass four different cookies to my page.
Unfortunately, setting cookies via headers didn’t work either.
Additional info:
NewCookie is a helper function I wrote myself: