wails icon indicating copy to clipboard operation
wails copied to clipboard

Iframe load other website can't save cookie?

Open songdemei opened this issue 2 years ago • 12 comments

Description

I add a iframe element in page . Open the app. View website ,that OK. But ,when I login to website ,they can't save my cookie??

To Reproduce

how can I store cookie in iframe?

Expected behaviour

I add a iframe element in page . Open the app. View website ,that OK. But ,when I login to website ,they can't save my cookie??

Screenshots

No response

Attempted Fixes

No response

System Details

mac os

Additional context

No response

songdemei avatar Mar 29 '23 13:03 songdemei

I had a similar problem, and I was fine in dev mode. But when I compiled and packaged macos I couldn't save the cookies

helloxz avatar Apr 13 '23 09:04 helloxz

You're going to be running in to a wall anytime you're trying to "share" cookies between iframes given policy restrictions, hostnam'ing, path'ing, etc.

By "can't save the cookie", what is the result exactly? Check the response payload from your login method(s) and see if the cookie is definitely being returned and then check the policies it's requesting to be enforced.

mateothegreat avatar Apr 16 '23 23:04 mateothegreat

When I open my other site using iframe,and login .They can't keep login stat ,but I use browser ,they work fine.

songdemei avatar Apr 19 '23 13:04 songdemei

@songdemei - have you tried with the latest version?

leaanthony avatar May 21 '23 08:05 leaanthony

@songdemei - have you tried with the latest version?

My wails version is 2.2 , I update to 2.5.1[latest version] When I run it using "wails dev" they can't start up , some error like this: WailsContext.m:221:28: error: property 'fraudulentWebsiteWarningEnabled' not found on object of type 'WKPreferences *' What can I do next?

songdemei avatar May 25 '23 07:05 songdemei

Please paste the output of wails doctor 👍

leaanthony avatar May 25 '23 08:05 leaanthony

` bogon:sxserver songdemei$ wails doctor Wails CLI v2.5.1

SUCCESS Done.

System

OS | MacOS
Version | 10.14.6 ID | 18G9323 Go Version | go1.19.4 Platform | darwin
Architecture | amd64

Wails

Version | v2.5.1

Dependencies

Dependency | Package Name | Status | Version Xcode command line tools | N/A | Installed | 2354
Nodejs | N/A | Installed | 16.3.0
npm | N/A | Installed | 7.15.1
*Xcode | N/A | Available |
*upx | N/A | Installed | upx 3.96 *nsis | N/A | Available |

    • Optional Dependency

Diagnosis

Your system is ready for Wails development! Optional package(s) installation details:

  • Xcode: Available at https://apps.apple.com/us/app/xcode/id497799835
  • nsis : More info at https://wails.io/docs/guides/windows-installer/

♥ If Wails is useful to you or your company, please consider sponsoring the project: https://github.com/sponsors/leaanthony `

songdemei avatar May 25 '23 13:05 songdemei

I create a empty project,output like this:

bogon:myproject songdemei$ wails dev Wails CLI v2.5.1

Executing: go mod tidy • Generating bindings: Done. • Installing frontend dependencies: Done. • Compiling frontend: Done.

[email protected] dev vite

Port 5173 is in use, trying another one...

VITE v3.2.6 ready in 387 ms

Vite Server URL: http://localhost:5174/ ➜ Local: http://localhost:5174/ ➜ Network: use --host to expose Running frontend DevWatcher command: 'npm run dev' Building application for development... • Generating bindings: Done. • Compiling application:

github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin

WailsContext.m:221:28: error: property 'fraudulentWebsiteWarningEnabled' not found on object of type 'WKPreferences *'

Build error - exit status 2 No version running, build will be retriggered as soon as changes have been detected watching: /xxx/xxx/xxx/xxx/myproject 。。。。。 Using DevServer URL: http://localhost:34115 Using Frontend DevServer URL: http://localhost:5174/ Using reload debounce setting of 100 milliseconds

To develop in the browser and call your bound Go methods from Javascript, navigate to: http://localhost:34115

songdemei avatar May 25 '23 14:05 songdemei

Please paste the output of wails doctor 👍

I can't run it yet! @leaanthony

songdemei avatar May 27 '23 13:05 songdemei

I down to V2.3.1 they run success. Now I see the request header and response header like this(login method):

Request POST /login/login HTTP/1.1 Accept: application/json, text/javascript, /; q=0.01 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Origin: http://127.0.0.1:8080 Referer: http://127.0.0.1:8080/login Content-Length: 30 Host: 127.0.0.1:8080 Accept-Language: zh-cn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) wails.io Accept-Encoding: gzip, deflate Connection: keep-alive X-Requested-With: XMLHttpRequest

Response HTTP/1.1 200 OK Set-Cookie: beegosessionID=37125b3dbeb51ebd9d03b8f4f9591c1d; Path=/; Max-Age=86400; HttpOnly; SameSite=Strict Content-Type: text/plain; charset=utf-8 Content-Length: 67 Date: Sun, 28 May 2023 08:40:56 GMT Server: beegoServer:2.0.0

And next ,I location to website root path: location.href='/' The request header loss my cookie:

Request GET / Referer: http://127.0.0.1:8080/login Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) wails.io Upgrade-Insecure-Requests: 1

songdemei avatar May 28 '23 08:05 songdemei

The possible reason is that cross domain. But when I open http://localhost:5174/ use my chrome browser ,that is OK,but use wails can't send cookie.

songdemei avatar May 29 '23 01:05 songdemei

@songdemei Did you manage to solve it?

frontRocha avatar Aug 16 '24 12:08 frontRocha

Looks like this issue conflated a bunch of different issues. Cookies in webviews aren't handled automatically as they are not browsers. However we are looking at implementing a Cookie Manager in v3.

leaanthony avatar Nov 23 '24 11:11 leaanthony