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?
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.
ohhh… it’s Groundhog Day
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
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)
// 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)
is this Mac? Win? Linux?
I have quite a few classes for this in my plugins.
[quote=260538:@Christian Schmitz]is this Mac? Win? Linux?
I have quite a few classes for this in my plugins.[/quote]
Now it is for a OSX application. At some point in the future I will need it for Windows as well.
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)
for each c as NSHTTPCookieMBS in cookies
dim d as string
dim e as date = c.expiresDate
if e<>Nil then
d = e.ShortDate
List.AddRow c.domain, c.name, c.value, c.path, d, c.comment
you can save them to your own database and restore them on next run.
I’m still not getting it.
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.
One can test it at this link: https://lic.seminar.pro
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”)
I get a web app error when I visit that in my browser.
Also none of the icons load until I change a quantity.
Who’s the payment processor? If it’s got english documentation I can take a peek.
Is it still there when you hit calculate?
What OS and browser?
Thank you for feedback!
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.
Thanks Tim! I think I know where to search …
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).
Step 1 : Cart
Step 2 : Confirmation
Step 3 : Saferpay error message
Expected Result :
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…
You should file a feature request.