Chinese garbled solve the cookie store

Development tools and key technologies: Visual Studio and cookie

Author: Huang Can

Write time: 2019.6.5

A cookie is a mechanism in the program, session tracking is a very important thing. cookie mechanism it can make up for lack of stateless HTTP protocol. Web applications using the HTTP protocol for transferring data, once the data transfer is complete, the client and the server will be disconnected again to transmit data need to re-establish a new connection, a new connection that the server can not connect from the trace session. cookie can be understood as a pass, like ID cards, holding identity card registration, go to where can be found when you have done what was going on, but server records the cookie when the user state, using response to customer tour certificate is issued by a record, access the URL link in the customer's browser when using the transmission's browser will put together the requested URL and cookie to the server, by checking the cookie will be able to know who you are and dry in the URL anything. But the cookie and differences of identity are: cookie is a server issued to a customer's browser, not after a server issues a cookie to record all the tour, a national ID card is worldwide.

Chinese cookie store will garbled, when using the cookie store Chinese need to use a specific program encoded Chinese.

Direct input of the content assigned to the cookie store

Here Insert Picture Description

View store a cookie break a string, there is no problem that can Chinese are stored into the cookie, and no problem in the storage process, pay attention to see [&] symbol, this [&] symbol is [and ] mean, two [&] is divided into three strings

Here Insert Picture Description

But using UrlDecode read the cookie will be stored in Chinese distortion, the Decode translated decoder, Chinese this way is stored in the cookie will be decoded as a number of symbols

Here Insert Picture Description

Breakpoints view to the string just read is stored in the cookie, where you can see the Chinese already read cookie store garbled, here short of a [&] sign that read only two strings

Here Insert Picture Description

Need to be backfilled account number, name, password, and only backfill account is correct, and the name of the Chinese have been compiled into a garbled, because the less a [&] symbol, only two strings, the characters in the password spliced ​​to the names which has the password as plain text as backfill to the input box among the names, passwords as plain text show up, like this is very dangerous.

Here Insert Picture Description

When using a specific cookie storage Chinese Chinese program code used during storage HttpUtility.UrlEncode (strUserName, Encoding.GetEncoding ( "UTF-8")) is stored, the first re-assignment to the encoding Chinese stored in the storage process Chinese , UTF-8 is a Chinese encoding

Here Insert Picture Description

The Chinese string breakpoints view to the first code storage, where you can see the need to store a cookie in the Chinese have been compiled into some numbers and symbols stored

Here Insert Picture Description

After reading the first cookie store encoded Chinese also need to put these characters in translated back into Chinese reading

Here Insert Picture Description

Breakpoints view or read cookie stored in storage after the first encoded Chinese, when read breakpoints view is seen time and store some of the same numbers and symbols, but when the assignment is already a Chinese font, you can break Move the mouse to point at the UserName view of what to read characters

Here Insert Picture Description

Such backfill account number, name, password are correct too backfill, the password will not backfill in clear text box to enter a name

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44542088/article/details/91348442