javascript - How to elegantly get the key value of a cookie by key name?
巴扎黑
巴扎黑 2017-05-16 13:23:38
0
3
564

Is it the only way to match the cookie key value corresponding to the specified key name using traditional regular expressions?

巴扎黑
巴扎黑

reply all(3)
刘奇

There’s no way, that’s how cookies are stored, piled together, and you can only retrieve them in this way. Regular expression is already a very elegant way.
If you want elegant key-value pairs, use localStorage/localSession

淡淡烟草味

You can only use regular string operations

PHPzhong

In fact, the simplest way is to use the cookie.js library to implement the operation. It is paired with jquery.cookie.js, and its API can be viewed. If you want to write native code, you can define your own functions to solve the problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template