Daan Poron Daan Poron - 1 month ago 18
HTML Question

Session only cookies with Javascript

I was wondering if it's possible to create session only cookies with Javascript. When the browser is closed the cookies should be removed.

I can't use anything on the server as the website is HTML only ... so no server side script is used.

I read something about this here:
http://blog.lysender.com/2011/08/setting-session-only-cookie-via-javascript/
but i can't find any more information about this ... so i was wondering if this method is reliable.

Answer

Yes, that is correct.

Not putting an expires part in will create a session cookie, whether it is created in JavaScript or on the server.

See http://stackoverflow.com/a/532660/1901857