sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.71k stars 1.94k forks source link

Cookies are being set in firefox but not chrome mobile #12540

Closed marijuana-softwares-1 closed 3 months ago

marijuana-softwares-1 commented 3 months ago

Describe the bug

hello i have problems working with cookies simply they are set when i work with firefox but not on chrome (mobile) and idk how to debug it to know where the problem is so maybe chrome is doing something weird or i am doing something wrong. i reported this issue cuz i was working on another project but couldn't step further due to this so i reset up everything and i am doing this to make more sens if it's my code, svelte or browser problem.

Reproduction

// (root)/+page.svelte
<script>
        export let data;
</script>

<h1>Welcome to { data?.name ?? 'sveltekit' }</h1>

// (root)/+page.server.js
export function load(event) {
        return {
                name: event.cookies.get("test")
        }
}

// (auth)/+page.server.js
import { redirect } from "@sveltejs/kit"
export const actions = {
        default: async (event) => {
                event.cookies.set("test", "Project",
                        path: '/',
                        maxage: process.env.COOKIE_MAXAGE, // 3600000
                        sameSite: 'strict',
                });
                throw redirect(302, "/")
        }
}

// (auth)/+page.svelte
<form method="POST">
        <button type="submit">Submit</button>
</form>

Logs

no logs

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 Intel(R) Core(TM)2 Duo CPU     P7550  @ 2.26GHz
    Memory: 730.14 MB / 3.79 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 18.19.0 - /usr/bin/node
    npm: 9.2.0 - /usr/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.2.2 
    @sveltejs/kit: ^2.0.0 => 2.5.19 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.1 
    svelte: ^4.2.7 => 4.2.18 
    vite: ^5.0.3 => 5.3.5

Severity

annoyance

Additional Information

No response

marijuana-softwares-1 commented 3 months ago

the problem was because i must set the secure to true or false. fixed no one should worry :)