I have a drop-down on my site that I want visible to any first-time visitor, but if the user closes it, then I want to keep it closed on next visit for the same user.
Can I do this just with jQuery or do I need to pass the state back to the server (开发者_Python百科via Ajax?) and use server's session capabilities?
Thank you
You can use cookies (to store the preference), or if you have authentication on your site, you could POST
back via AJAX and update your users preferences (this will have the advantage of not relying on cookies expiring/being deleted).
You need to use cookies, it can be achieved with plain javascript. This is a nice resource for learning to deal with cookies.
精彩评论