简体   繁体   中英

Should i set cookie with JavaScript or with a server-side language?

I know some people disable JavaScript with NoScript add-on so their browser can't run any scripts. Accordingly i won't set cookies. So should i avoid the Javascript way?

Is there have prefered way to set cookies? Is there any exceptions to the rules? Or there have no rules it all?

If the setting of the cookie is related to JavaScript, then use the JavaScript way. For everything else have the server set them.

However, you could use localStorage to replace those "JavaScript cookies", if there is no need for the server to know about them.

通常,您应该使用服务器端技术,因为加密cookie内容也变得更加容易。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM