Setting cookie in Safari for iOS

I can no longer set a cookie in Safari for iOS in a web app.

Has something changed?

2025-02-13

1 Like

Are you doing it securely? Apple’s been tightening bolts on Safari.

Can you explain what you mean by doing it securely?

Here’s the command:

session.cookies.set(“CircleCalc_MAG_login_info”, session.identifier, dateTime.now.addInterval(1, 0, 0))

Website url being https://

https://cclamag.xojocloud.net/

Unfortunately that was my only “not at my desk” debug idea.

I wonder if @Ricardo_Cruz_Fernandez has heard anything about this.

I’ll have to test this in my computer. If you’re using https, it should work just fine.

What version of Xojo are you using @John_Scanlan ?

I cannot reproduce this issue, in both desktop and mobile it seems to be storing the cookie:

https://ricardocookies.xojocloud.net

2 Likes

2024 4.2

I’ve deployed the sample project again with that version and it still works, it has to be something else.

Could be an exception happening before setting the cookie? Are you implementing UnhandledException to see if there is something going wrong?

1 Like

I’ve been stepping thru the debug and it’s running the set cookie command.

Can you provide the app so I can see what you’re doing?

Sure John, here it is:

CookiesTest.xojo_binary_project.zip (8.5 KB)

I’ve copied/pasted your code, I’ve just changed the cookie name.

Okay this is weird. On my desktop (windows) I get a cookie called “testing-ricardo” with the value of the session identifier. On my iphone I get a cookie called “cookietest” with the value of 1.

cookietest doesn’t exist in your app.

That sounds like a cookie stored from another test project maybe?

I keep deleting cookietest and it keeps coming back.

So I ran into an issue similar to this today. After some investigating, it was because I was using Session.Cookies.Set inside the Action event of a WebTimer on the Server.

Maybe this is what you’re seeing? Here’s a project to play with: https://tim.gd/4RTOM

I’m not sure if it’s supposed to be raising a SessionNotAvailableException or if this is specific to Cookies. I can open a ticket, @Ricardo_Cruz. What is the expected behavior is for this scenario?

1 Like

When the WebTimer location is set to Server, as the action response is coming from the EventSource connection, it won’t receive the Set-Cookie HTTP header. I think we can find a way to overcome this problem, could you please create that ticket?

1 Like

Created #78773 - Session.Cookies.Set failing silently

2 Likes