wails icon indicating copy to clipboard operation
wails copied to clipboard

Cookies cannot be set on macos

Open helloxz opened this issue 2 years ago • 13 comments

Description

I am on the macos platform. I can normally set cookies in dev mode, but setting cookies after build is invalid.

I did a comparison check with debug mode and found this to be the case.

To Reproduce

run wails dev ok

document.cookie = "username=John Doe; expires=" + new Date(new Date().getTime() + (24 * 60 * 60 * 1000)).toUTCString() + "; path=/";

run wails build -debug failed

document.cookie = "username=John Doe; expires=" + new Date(new Date().getTime() + (24 * 60 * 60 * 1000)).toUTCString() + "; path=/";

Expected behaviour

Cookies can be set correctly and effectively

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.4.1

Scanning system - Please wait (this may take a long time)...Done.

# System

OS           | MacOS   
Version      | 13.3.1  
ID           | 22E261  
Go Version   | go1.20.3
Platform     | darwin  
Architecture | amd64   

# Wails

Version | v2.4.1

# Dependencies

Dependency                | Package Name | Status    | Version  
Xcode command line tools  | N/A          | Installed | 2397     
npm                       | N/A          | Installed | 9.5.0    
*Xcode                    | N/A          | Available |          
*upx                      | N/A          | Installed | upx 4.0.2
*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

Additional context

No response

helloxz avatar Apr 13 '23 13:04 helloxz

Is your expectation that webviews support cookies? Do they?

leaanthony avatar Apr 13 '23 14:04 leaanthony

  • wails dev(support cookies)
  • wails build(not suppot cookies)

I hope the wails build can also support setting cookies

helloxz avatar Apr 13 '23 14:04 helloxz

Excuse me, have you reproduced this BUG?

helloxz avatar Apr 14 '23 06:04 helloxz

In my opinion, having no cookie support does not posed a critical issue. Since it can be handled by either LocalStorage (which hadn't been an issue for me) or perhaps by the golang/backend side of the wails app. Cookie imho much more appropriate for web development which run on full fledge browser. Again, this is just my opinion

evorts avatar Apr 14 '23 16:04 evorts

It is not recommended to use Wails as a browser. 👀

misitebao avatar Apr 14 '23 16:04 misitebao

Yeah, Wails doesn't bundle a browser.

leaanthony avatar Apr 14 '23 20:04 leaanthony

Yeah, Wails doesn't bundle a browser.

It's a bit strange that cookies are supported in development mode, but not after packaging. This issue doesn't exist on Windows. What could be the reason? I've temporarily switched to using localStorage to work around this problem.

helloxz avatar Apr 16 '23 03:04 helloxz

When you say "development mode", do they work in the app (not the browser)?

leaanthony avatar Apr 16 '23 10:04 leaanthony

When you say "development mode", do they work in the app (not the browser)?

Yes, it works in the application, not in the browser.

helloxz avatar Apr 17 '23 01:04 helloxz

@helloxz - Can you please retest with the latest version. Thanks.

leaanthony avatar May 21 '23 00:05 leaanthony

This looks like an issue. I am not able to set cookies even on windows. It fails both dev and build mode

adityak368 avatar Jul 24 '23 21:07 adityak368

yeah responses will show that there are cookies, but it looks like that there is no cookie storage implemented.

image

image

airtonix avatar Aug 07 '24 13:08 airtonix

Same is the case with me.. I am using securetokens to handle authentication. SecureTokens will try to set the cookie, but I am getting the following error image I dont see this issue when I visit the url directly in Safari . I am on MacOS

gj1118 avatar Aug 31 '24 15:08 gj1118

Moving all cookie related feedback to #3908

leaanthony avatar Nov 23 '24 23:11 leaanthony