MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

[Feature]: Cookies are not rememberred? #4876

Open int255 opened 2 weeks ago

int255 commented 2 weeks ago

Describe the feature/enhancement you need

I created my own web view using MSWebView2 (Win32/C++), but I noticed the cookies are not remembered each time I open up a new WebView2 interface. I looked at the SDK document and didn't find a clue how to tell WebView2 to preserve cookies or discard cookies.

For example I'm testing by navigating my MSWebView2 using https://setcookie.net/, I can set my cookie "aaa=bbb", the cookie is gone if I close my MSWebView2 and re-create a new view, (my application is still opened)

I'm not quite sure if this is an un-supported feature or may be I'm not initializing my MSWebView2 in a correct way? In my opinion, MSWebView2 should preserve the cookie when a new instance is created, and it should give client an API option to "not using cookies" during the construction.

The scenario/use case where you would use this feature

Just generic browsing

How important is this request to you?

Impactful. My app's user experience would be significantly compromised without it.

Suggested implementation

I'm not quite sure if this is an un-supported feature or may be I'm not initializing my MSWebView2 in a correct way? In my opinion, MSWebView2 should preserve the cookie when a new instance is created, and it should give client an API option to "not using cookies" during the construction.

What does your app do? Is there a pending deadline for this request?

My application does web-based sign in.

jls28 commented 2 weeks ago

From this page I created a simple cookie :

Sent header: Set-Cookie: AAA=BBB; path=/; HttpOnly

the cookie does not persit because this is a session cookie.

but if you add an expiration date this ok :

Sent header: Set-Cookie: AAA=BBB; expires=Thu, 24 Oct 2024 06:45:00 GMT; Max-Age=86366; path=/; HttpOnly

It seem than if you don't supply an expiration date this page create a session cookie.