Skip to content

Anybody having trouble removing cookies? #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lovasoa opened this issue Jun 1, 2024 Discussed in #361 · 0 comments
Closed

Anybody having trouble removing cookies? #368

lovasoa opened this issue Jun 1, 2024 Discussed in #361 · 0 comments

Comments

@lovasoa
Copy link
Collaborator

lovasoa commented Jun 1, 2024

Discussed in #361

Originally posted by E8y2FqZE May 31, 2024
I've made a "flash message" using the alert component that I want to show exactly once when someone successfully updates a resource. So for example if I set a cookie like this:

update users set
	name = :name,
	email = :email
	where id = :id;

select 'cookie' as component,
	'admin.alert.title' as name,
	'User updated' as value;

select 'redirect' as component,
	'user.sql?user=' || :id as link;

This cookie is correctly set.

image

And then in the page that it redirects to, I do this:

-- clear flash cookie
select 'cookie' as component, 'admin.alert.title' as name, true as remove;

--- display the value
select 'alert' as component,
	sqlpage.cookie('admin.alert.title') as title,
	'green' as color
	where sqlpage.cookie('admin.alert.title') is not null;

The alert is correctly displayed, and I can see that the HTTP headers are trying to unset the cookie in the response (expiration date is in the past):

image

Frustratingly, Firefox and Chrome are both hanging on to the cookie and thus I'm continuing to see the alert. I don't think this is a technical problem with SQLPage because it looks like the correct HTTP header is being sent to remove the cookie, but I just can't wrap my mind around why this isn't working. In desperation I tried this, which does work.

select 'cookie' as component, 'admin.alert.title' as name, unixepoch() as expires, '' as value;

My computer clock is correct, so I am baffled at why true as remove doesn't work...

@lovasoa lovasoa closed this as completed in 6c68d1d Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant