Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

infinite jQuery cookie

I plan to use some music on my site, but before I make it autoplay for each visitor, I would like to have either an alert pop up immediately, asking if they would like the music to play, or a nice little tooltip of some sort to present a message stating that you can check whether or not you would like the music.

So, I know I can set a cookie via the cookie plugin but I was wondering if I could set the cookie's time to infinite, in other words, never to delete it, unless the end-user deletes all of their cookies, or the specific one for my site.

Is this not considered a valid use of cookies? If not, for a task like this, what should time do you suggest I set it to?

like image 424
Qcom Avatar asked Dec 13 '22 20:12

Qcom


1 Answers

Something like 10 years is infinite enough for this ever-changing web realm ;)

$.cookie('the_cookie', 'the_value', { expires: 365 * 10 });
like image 101
Lukman Avatar answered Jan 02 '23 14:01

Lukman