tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.38k stars 2.58k forks source link

[feat] Add Set Cookie API to Webview #11691

Open murnifine opened 1 week ago

murnifine commented 1 week ago

Describe the problem

I need an API that can set cookies like the API made by electron, or like the chrome extension API

Describe the solution you'd like

    let webview = tauri::webview::WebviewBuilder::new(
        "tauri_main",
        WebviewUrl::External("mywebsite.com".parse().unwrap())
    );

    let res = data;

    webview.set_cookie({
        name: res.name,
        value: res.value,
        domain: res.domain,
        path: res.path,
        expirationDate: res.expirationDate,
        httpOnly: res.httpOnly,
        sameSite: res.sameSite,
        secure: res.secure,
        storeId: e.storeId: res.storeId,
        url: res.url
    });

Alternatives considered

No response

Additional context

https://www.electronjs.org/docs/latest/api/cookies#cookiessetdetails https://developer.chrome.com/docs/extensions/reference/api/cookies?hl=id#method-set