When I use the sample project TabbedWebBrowser.xojo_binary_project, then I cannot use it to surf to sites which require cookies.
What needs to be done to mimic the behavior of a standard web-browser to handle cookies?
I guess one would have to store cookies and then make sure they are readable again later?
Background:
I have a shopping cart webapp (Xojo) which then calls a payment terminal from a payment provider, and I would like to call this webapp from a desktop application. it fails, because I don’t know how to handle the cookies which the payment terminal seemingly tries to store and access again.
With built-in Webkit Engine this is - as far as I know - unpossible. Except you use MBS tools as Christian mentioned above.
For windows there’s a small workaround. You have to add your App in Windows Registry, so that you won’t use an outdated and limited IE Engine.
I am using a helper class (TheCore ) for writing/reading Windows Registry (Sys.ReadRegistry/Sys.WriteRegistry) using this snippet to enable current rendering IE engine with Cookies. Just replace XXXX.exe with your exe-filename.
// Registry Hack für Windows Platform damit HTML Viewer ohne Einschränkungen läuft
#if TargetWin32
dim Sys as new TheCore
dim b as Boolean = false
// 32 Bit on 64 Bit System
if cstr(Sys.ReadRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION","XXXX.exe")) = "" then
b = Sys.WriteRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION","XXXX.exe",11999,1)
end if
// 32Bit only System (or 64 Bit)
if b=false and cstr(Sys.ReadRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION","XXXX.exe")) = "" then
b = Sys.WriteRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION","XXXX.exe",11999,1)
end if
#endif
So I found this code in the “Mac Cookies” MBS sample project. As far as I understand, it will help to retrieve cookies which come from a website.
How do I intercept a call to read cookies, when the same website tries to get hands on those cookies again, lateron?
Is there a way to find out which cookies are expected to be found?
A normal webbrowser is taking care of all these things, saving and returning cookies from/to a website.
How can this be done in a htmlviewer in a desktop app?
[code]dim storage as NSHTTPCookieStorageMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage
dim cookies() as NSHTTPCookieMBS = storage.cookiesForURL(TextField1.Text)
List.deleteAllRows
for each c as NSHTTPCookieMBS in cookies
dim d as string
dim e as date = c.expiresDate
if e<>Nil then
d = e.ShortDate
end if
List.AddRow c.domain, c.name, c.value, c.path, d, c.comment
I have a shopping cart webapp (Xojo) which then calls a payment terminal from a payment provider, and I would like to call this webapp from a desktop application.
This fails, because I don’t know how to handle the cookies which the payment terminal seemingly tries to store and access again.
The payment terminal is third party webapp and it seems to try to save and restore cookies, which fails when called from an htmlviewer of a desktop app.
So how can this payment terminal app save and restore its cookies? (These are not cookies from my webapp)
My own xojo webapp first collects data and then builds an url string which i send via httpsecuresocket.get to the payment terminal.
When i open the link in a standard webbrowser, the the saferpay terminal appears. When i call the same url from a htmlviewer, then it fails (“no cookies”)
It appears before I do anything when loading the page.
10.11.4 / Safari 9.1 (11601.5.17.1)
Reading the description, it looks like a problem with trying to use .innerHTML on an item that doesn’t exist yet. Coupled with the page icons not showing up until I hit calculate, I bet it has something to do with those.
I still don’t know how to store and return cookies from a OSX htmlviewer desktop app, for a third party website.
The website is moaning about missing cookies (see screenshot below)
Here my htmlviewer testproject for the desktop: download
The app should show up with a xojo webapp in htmlviewer.
After adding a license to a cart one goes to the 2nd screen to fill out some address data and confirm terms and conditions. Then one clicks continue and now in our webapp we use httpsecuresocket.get to open the terminal of the payment provider.
This works from a standard browser, but not from a htmlviewer. Apparently because we don’t handle cookies (see screenshot below).
I still don’t know how to store and return cookies of websites which I open in a desktop htmlviewer, but my specific problem has been solved by itself. Since yesterday SIX saferpay terminal has been updated and no longer requires cookies. Great for me!
But I still wished, htmlviewer would handle cookies of websites behind the scene, just as a standard webbrowser does…