Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Interceptor+Cookie is used in SpringMVC to realize automatic login within a certain number of days.

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

After clicking on login, you can find that the page jumps to: http://localhost:9180/CookieDemo/user/index.html

At the same time, a cookie record value named "remember-me" is generated, and its value is: YWRtaW46YzhjYTU3NjktNDhjZi00NWQ4LTk4YzQtM2QzMDMwNWVlMWY5

If you use the online base64 decoding tool to decode it, you can find that the original text of this cookie value is:

It corresponds exactly to the record in the persistent_ logs table in the database:

Then, after exiting the browser, open the browser again to access: http://localhost:9180/CookieDemo/user/index.html

It can be found that the page can be accessed directly and is already logged in. At this point, our goal has been achieved.

(2) after testing login, jump back to the page you originally wanted to visit:

Delete the cookie of "remember-me" in the browser, or delete the record in the persistent_ logs table in the database, and then visit: http://localhost:9180/CookieDemo/user/callback.html after logging out

As you can see, the page has been automatically redirected to the login page

Then, enter the user name and password to log in, and you can find that after the login is successful, you can jump to the page we originally requested:

Attached: the complete source code of this test project:

Link: http://pan.baidu.com/s/1nvo72a9 password: dkxa

PS: the watermark in the above picture is the domain name of my personal blog, so please show mercy not to mark me as "reprinted article", thank you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report