{"id":63455,"date":"2026-01-22T00:32:35","date_gmt":"2026-01-21T16:32:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/63455.html"},"modified":"2026-01-22T00:32:35","modified_gmt":"2026-01-21T16:32:35","slug":"%e5%9f%ba%e4%ba%8esession%e5%ae%9e%e7%8e%b0%e7%99%bb%e5%bd%95%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/63455.html","title":{"rendered":"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b"},"content":{"rendered":"<h3>\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5b66 Session \u767b\u5f55&#xff1f;<\/h3>\n<p>\u5728 JWT\u3001OAuth2\u3001Token \u98ce\u9761\u7684\u4eca\u5929&#xff0c;\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;<\/p>\n<p>\u201c\u73b0\u5728\u8fd8\u6709\u4eba\u7528 Session \u5417&#xff1f;\u201d<\/p>\n<p>\u7b54\u6848\u662f&#xff1a;\u6709&#xff01;\u800c\u4e14\u5f88\u591a&#xff01;<\/p>\n<ul>\n<li>\u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf&#xff08;\u5982 OA\u3001ERP&#xff09;\u4ecd\u5e7f\u6cdb\u4f7f\u7528 Session<\/li>\n<li>\u5bf9\u5b89\u5168\u6027\u8981\u6c42\u9ad8\u3001\u9700\u5f3a\u4f1a\u8bdd\u63a7\u5236\u7684\u573a\u666f&#xff08;\u5982\u94f6\u884c\u540e\u53f0&#xff09;<\/li>\n<li>\u4e0d\u9700\u8981\u8de8\u57df\u3001\u4e0d\u8ffd\u6c42\u65e0\u72b6\u6001\u7684\u4e2d\u5c0f\u578b Web \u5e94\u7528<\/li>\n<\/ul>\n<p>Session \u662f\u7406\u89e3 Web \u8ba4\u8bc1\u673a\u5236\u7684\u57fa\u77f3\u3002\u638c\u63e1\u5b83&#xff0c;\u4f60\u624d\u80fd\u771f\u6b63\u7406\u89e3\u201c\u767b\u5f55\u201d\u80cc\u540e\u7684\u539f\u7406\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60&#xff1a;<br \/>\n\u2705 \u6df1\u5165 Session \u5de5\u4f5c\u539f\u7406<br \/>\n\u2705 \u624b\u52a8\u5b9e\u73b0\u5b8c\u6574\u767b\u5f55\/\u767b\u51fa\u6d41\u7a0b<br \/>\n\u2705 \u5728 Spring Boot \u4e2d\u5b89\u5168\u4f7f\u7528 Session<br \/>\n\u2705 \u907f\u5f00\u5e38\u89c1\u5b89\u5168\u9677\u9631<\/p>\n<hr \/>\n<h3>\u4e8c\u3001Session \u767b\u5f55\u539f\u7406\u56fe\u89e3<\/h3>\n<p>       &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;        &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n       |    \u6d4f\u89c8\u5668       |        |     \u670d\u52a1\u5668        |<br \/>\n       &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;        &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;<br \/>\n                |                         |<br \/>\n1. \u63d0\u4ea4\u7528\u6237\u540d\u5bc6\u7801 | POST \/login             |<br \/>\n                |&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&gt;|<br \/>\n                |                         |<br \/>\n2. \u9a8c\u8bc1\u6210\u529f      | \u521b\u5efa Session            |<br \/>\n                | \u5b58\u50a8\u7528\u6237\u4fe1\u606f            |<br \/>\n                | Set-Cookie: JSESSIONID&#061;abc123<br \/>\n                |&lt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;|<br \/>\n                |                         |<br \/>\n3. \u540e\u7eed\u8bf7\u6c42      | Cookie: JSESSIONID&#061;abc123<br \/>\n                |&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&gt;|<br \/>\n                | \u670d\u52a1\u5668\u6839\u636e ID \u627e\u5230 Session<br \/>\n                | \u786e\u8ba4\u7528\u6237\u5df2\u767b\u5f55           |<br \/>\n                |                         |<br \/>\n4. \u70b9\u51fb\u9000\u51fa      | GET \/logout             |<br \/>\n                |&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&gt;|<br \/>\n                | \u5220\u9664 Session            |<br \/>\n                | Clear Cookie            |<br \/>\n                |&lt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;|<\/p>\n<p>&#x1f511;\u00a0\u6838\u5fc3\u673a\u5236&#xff1a;<\/p>\n<ul>\n<li>\u670d\u52a1\u5668\u521b\u5efa\u00a0HttpSession&#xff0c;\u751f\u6210\u552f\u4e00 ID&#xff08;\u5982\u00a0JSESSIONID&#xff09;<\/li>\n<li>\u901a\u8fc7\u00a0Set-Cookie\u00a0\u5c06 ID \u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668<\/li>\n<li>\u6d4f\u89c8\u5668\u540e\u7eed\u8bf7\u6c42\u81ea\u52a8\u643a\u5e26\u8be5 Cookie<\/li>\n<li>\u670d\u52a1\u5668\u901a\u8fc7 ID \u67e5\u627e Session&#xff0c;\u9a8c\u8bc1\u767b\u5f55\u72b6\u6001<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e09\u3001Spring Boot \u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b<\/h3>\n<h4>1. \u9879\u76ee\u4f9d\u8d56&#xff08;\u65e0\u9700\u989d\u5916\u5f15\u5165&#xff09;<\/h4>\n<p>&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt;<br \/>\n&lt;!&#8211; \u5185\u5d4c Tomcat \u81ea\u5e26 Session \u652f\u6301 &#8211;&gt;<\/p>\n<p>&#x1f4a1; Spring Boot \u9ed8\u8ba4\u4f7f\u7528\u00a0\u5185\u5b58\u5b58\u50a8 Session&#xff08;\u91cd\u542f\u4e22\u5931&#xff09;&#xff0c;\u751f\u4ea7\u73af\u5883\u53ef\u96c6\u6210 Redis&#xff08;\u89c1\u540e\u6587&#xff09;\u3002<\/p>\n<hr \/>\n<h4>2. \u7528\u6237\u5b9e\u4f53\u4e0e\u6a21\u62df\u6570\u636e\u5e93<\/h4>\n<p>public class User {<br \/>\n    private String username;<br \/>\n    private String password; \/\/ \u5b9e\u9645\u5e94\u5b58 BCrypt \u52a0\u5bc6\u540e\u7684\u503c<br \/>\n    \/\/ getter\/setter&#8230;<br \/>\n}<\/p>\n<p>&#064;Component<br \/>\npublic class UserDatabase {<br \/>\n    private static final Map&lt;String, User&gt; users &#061; new HashMap&lt;&gt;();<\/p>\n<p>    static {<br \/>\n        \/\/ \u6a21\u62df\u7528\u6237&#xff1a;admin \/ 123456<br \/>\n        users.put(&#034;admin&#034;, new User(&#034;admin&#034;, &#034;123456&#034;));<br \/>\n    }<\/p>\n<p>    public User findByUsername(String username) {<br \/>\n        return users.get(username);<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h4>3. \u767b\u5f55\u63a7\u5236\u5668&#xff08;\u6838\u5fc3\u903b\u8f91&#xff09;<\/h4>\n<p>&#064;Controller<br \/>\npublic class LoginController {<\/p>\n<p>    &#064;Autowired<br \/>\n    private UserDatabase userDatabase;<\/p>\n<p>    \/\/ \u8df3\u8f6c\u5230\u767b\u5f55\u9875<br \/>\n    &#064;GetMapping(&#034;\/login&#034;)<br \/>\n    public String loginPage() {<br \/>\n        return &#034;login&#034;; \/\/ \u8fd4\u56de templates\/login.html<br \/>\n    }<\/p>\n<p>    \/\/ \u5904\u7406\u767b\u5f55\u8bf7\u6c42<br \/>\n    &#064;PostMapping(&#034;\/login&#034;)<br \/>\n    public String login(&#064;RequestParam String username,<br \/>\n                        &#064;RequestParam String password,<br \/>\n                        HttpSession session,<br \/>\n                        RedirectAttributes redirectAttributes) {<\/p>\n<p>        \/\/ 1. \u6821\u9a8c\u53c2\u6570<br \/>\n        if (username &#061;&#061; null || username.trim().isEmpty()) {<br \/>\n            redirectAttributes.addFlashAttribute(&#034;error&#034;, &#034;\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a&#034;);<br \/>\n            return &#034;redirect:\/login&#034;;<br \/>\n        }<\/p>\n<p>        \/\/ 2. \u67e5\u8be2\u7528\u6237<br \/>\n        User user &#061; userDatabase.findByUsername(username);<br \/>\n        if (user &#061;&#061; null || !user.getPassword().equals(password)) {<br \/>\n            redirectAttributes.addFlashAttribute(&#034;error&#034;, &#034;\u7528\u6237\u540d\u6216\u5bc6\u7801\u9519\u8bef&#034;);<br \/>\n            return &#034;redirect:\/login&#034;;<br \/>\n        }<\/p>\n<p>        \/\/ 3. \u767b\u5f55\u6210\u529f&#xff1a;\u5c06\u7528\u6237\u4fe1\u606f\u5b58\u5165 Session<br \/>\n        session.setAttribute(&#034;currentUser&#034;, user.getUsername());<br \/>\n        session.setMaxInactiveInterval(30 * 60); \/\/ 30\u5206\u949f\u65e0\u64cd\u4f5c\u81ea\u52a8\u8fc7\u671f<\/p>\n<p>        return &#034;redirect:\/home&#034;;<br \/>\n    }<\/p>\n<p>    \/\/ \u4e3b\u9875&#xff08;\u9700\u767b\u5f55&#xff09;<br \/>\n    &#064;GetMapping(&#034;\/home&#034;)<br \/>\n    public String home(HttpSession session, Model model) {<br \/>\n        String currentUser &#061; (String) session.getAttribute(&#034;currentUser&#034;);<br \/>\n        if (currentUser &#061;&#061; null) {<br \/>\n            return &#034;redirect:\/login&#034;;<br \/>\n        }<br \/>\n        model.addAttribute(&#034;user&#034;, currentUser);<br \/>\n        return &#034;home&#034;;<br \/>\n    }<\/p>\n<p>    \/\/ \u9000\u51fa\u767b\u5f55<br \/>\n    &#064;GetMapping(&#034;\/logout&#034;)<br \/>\n    public String logout(HttpSession session) {<br \/>\n        session.invalidate(); \/\/ \u9500\u6bc1\u6574\u4e2a Session<br \/>\n        return &#034;redirect:\/login&#034;;<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h4>4. \u7b80\u5355\u524d\u7aef\u9875\u9762&#xff08;Thymeleaf&#xff09;<\/h4>\n<p>templates\/login.html<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html xmlns:th&#061;&#034;http:\/\/www.thymeleaf.org&#034;&gt;<br \/>\n&lt;head&gt;&lt;title&gt;\u767b\u5f55&lt;\/title&gt;&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n  &lt;h2&gt;\u7528\u6237\u767b\u5f55&lt;\/h2&gt;<br \/>\n  &lt;div th:if&#061;&#034;${error}&#034; style&#061;&#034;color:red;&#034; th:text&#061;&#034;${error}&#034;&gt;&lt;\/div&gt;<\/p>\n<p>  &lt;form method&#061;&#034;post&#034; action&#061;&#034;\/login&#034;&gt;<br \/>\n    \u7528\u6237\u540d: &lt;input type&#061;&#034;text&#034; name&#061;&#034;username&#034; required&gt;&lt;br&gt;&lt;br&gt;<br \/>\n    \u5bc6\u7801:   &lt;input type&#061;&#034;password&#034; name&#061;&#034;password&#034; required&gt;&lt;br&gt;&lt;br&gt;<br \/>\n    &lt;button type&#061;&#034;submit&#034;&gt;\u767b\u5f55&lt;\/button&gt;<br \/>\n  &lt;\/form&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>templates\/home.html<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;&lt;title&gt;\u4e3b\u9875&lt;\/title&gt;&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n  &lt;h2&gt;\u6b22\u8fce&#xff0c;&lt;span th:text&#061;&#034;${user}&#034;&gt;&lt;\/span&gt;&#xff01;&lt;\/h2&gt;<br \/>\n  &lt;a href&#061;&#034;\/logout&#034;&gt;\u9000\u51fa\u767b\u5f55&lt;\/a&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<hr \/>\n<h3>\u56db\u3001\u5173\u952e\u7ec6\u8282\u89e3\u6790<\/h3>\n<h4>1.\u00a0HttpSession\u00a0\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<ul>\n<li>\u7531 Servlet \u5bb9\u5668&#xff08;\u5982 Tomcat&#xff09;\u63d0\u4f9b<\/li>\n<li>\u6bcf\u4e2a\u4f1a\u8bdd\u4e00\u4e2a\u5b9e\u4f8b&#xff0c;\u7ebf\u7a0b\u5b89\u5168<\/li>\n<li>\u6570\u636e\u5b58\u50a8\u5728\u670d\u52a1\u7aef\u5185\u5b58\u4e2d<\/li>\n<li>\u751f\u547d\u5468\u671f&#xff1a;\u521b\u5efa \u2192 \u4f7f\u7528 \u2192 \u8d85\u65f6\/\u624b\u52a8\u9500\u6bc1<\/li>\n<\/ul>\n<h4>2.\u00a0session.setAttribute()\u00a0\u5b58\u4ec0\u4e48&#xff1f;<\/h4>\n<ul>\n<li>\u2705 \u63a8\u8350&#xff1a;\u53ea\u5b58\u5fc5\u8981\u6807\u8bc6&#xff08;\u5982 userId\u3001username&#xff09;<\/li>\n<li>\u274c \u907f\u514d&#xff1a;\u5b58\u5927\u5bf9\u8c61&#xff08;\u5982\u7528\u6237\u5b8c\u6574\u4fe1\u606f\u3001\u8ba2\u5355\u5217\u8868&#xff09;<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>session.setAttribute(&#034;userId&#034;, 1001); \/\/ \u597d<br \/>\nsession.setAttribute(&#034;user&#034;, fullUserObject); \/\/ \u4e0d\u63a8\u8350<\/p>\n<h4>3. \u5982\u4f55\u4fdd\u62a4\u63a5\u53e3\u4e0d\u88ab\u672a\u767b\u5f55\u8bbf\u95ee&#xff1f;<\/h4>\n<p>\u65b9\u5f0f\u4e00&#xff1a;\u6bcf\u4e2a Controller \u624b\u52a8\u68c0\u67e5<\/p>\n<p>&#064;GetMapping(&#034;\/profile&#034;)<br \/>\npublic String profile(HttpSession session) {<br \/>\n    if (session.getAttribute(&#034;currentUser&#034;) &#061;&#061; null) {<br \/>\n        return &#034;redirect:\/login&#034;;<br \/>\n    }<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p>\u65b9\u5f0f\u4e8c&#xff1a;\u4f7f\u7528\u62e6\u622a\u5668&#xff08;\u63a8\u8350&#xff09;<\/p>\n<p>&#064;Component<br \/>\npublic class LoginInterceptor implements HandlerInterceptor {<br \/>\n    &#064;Override<br \/>\n    public boolean preHandle(HttpServletRequest request,<br \/>\n                             HttpServletResponse response,<br \/>\n                             Object handler) throws Exception {<br \/>\n        HttpSession session &#061; request.getSession(false);<br \/>\n        if (session &#061;&#061; null || session.getAttribute(&#034;currentUser&#034;) &#061;&#061; null) {<br \/>\n            response.sendRedirect(&#034;\/login&#034;);<br \/>\n            return false;<br \/>\n        }<br \/>\n        return true;<br \/>\n    }<br \/>\n}<\/p>\n<p>&#064;Configuration<br \/>\npublic class WebConfig implements WebMvcConfigurer {<br \/>\n    &#064;Override<br \/>\n    public void addInterceptors(InterceptorRegistry registry) {<br \/>\n        registry.addInterceptor(new LoginInterceptor())<br \/>\n                .addPathPatterns(&#034;\/home&#034;, &#034;\/profile&#034;, &#034;\/settings\/**&#034;)<br \/>\n                .excludePathPatterns(&#034;\/login&#034;, &#034;\/css\/**&#034;, &#034;\/js\/**&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5b89\u5168\u52a0\u56fa&#xff1a;\u907f\u5f00\u5e38\u89c1\u9677\u9631<\/h3>\n<h4>&#x1f512; \u5751 1&#xff1a;\u5bc6\u7801\u660e\u6587\u5b58\u50a8\/\u4f20\u8f93<\/h4>\n<ul>\n<li>\u4fee\u590d&#xff1a;\u524d\u7aef HTTPS &#043; \u540e\u7aef BCrypt \u52a0\u5bc6\n<p>\/\/ \u5b58\u50a8\u65f6\u52a0\u5bc6<br \/>\nString hashedPassword &#061; BCrypt.hashpw(rawPassword, BCrypt.gensalt());<br \/>\n\/\/ \u9a8c\u8bc1\u65f6\u6bd4\u5bf9<br \/>\nif (BCrypt.checkpw(inputPassword, storedHash)) { &#8230; }\n<\/li>\n<\/ul>\n<h4>&#x1f512; \u5751 2&#xff1a;Session \u52ab\u6301&#xff08;XSS &#043; Cookie \u7a83\u53d6&#xff09;<\/h4>\n<ul>\n<li>\u4fee\u590d&#xff1a;\u8bbe\u7f6e Cookie \u5b89\u5168\u5c5e\u6027\n<p># application.yml<br \/>\nserver:<br \/>\n  servlet:<br \/>\n    session:<br \/>\n      cookie:<br \/>\n        http-only: true   # \u7981\u6b62 JS \u8bbf\u95ee Cookie<br \/>\n        secure: false     # \u751f\u4ea7\u73af\u5883 HTTPS \u65f6\u8bbe\u4e3a true<br \/>\n        same-site: strict # \u9632 CSRF&#xff08;\u90e8\u5206\u6d4f\u89c8\u5668\u652f\u6301&#xff09;\n<\/li>\n<\/ul>\n<h4>&#x1f512; \u5751 3&#xff1a;Session \u56fa\u5b9a\u653b\u51fb<\/h4>\n<ul>\n<li>\u73b0\u8c61&#xff1a;\u653b\u51fb\u8005\u8bf1\u5bfc\u7528\u6237\u4f7f\u7528\u5df2\u77e5 Session ID<\/li>\n<li>\u4fee\u590d&#xff1a;\u767b\u5f55\u6210\u529f\u540e\u66f4\u6362 Session ID\n<p>\/\/ \u5728 login \u6210\u529f\u540e<br \/>\nsession &#061; request.getSession(); \/\/ \u83b7\u53d6\u5f53\u524d session<br \/>\nsession.invalidate();           \/\/ \u9500\u6bc1\u65e7 session<br \/>\nsession &#061; request.getSession(true); \/\/ \u521b\u5efa\u65b0 session<br \/>\nsession.setAttribute(&#034;currentUser&#034;, username);\n<\/li>\n<\/ul>\n<p>\u2705 Spring Security \u9ed8\u8ba4\u5df2\u5904\u7406\u6b64\u95ee\u9898&#xff0c;\u4f46\u624b\u5199\u767b\u5f55\u9700\u6ce8\u610f&#xff01;<\/p>\n<hr \/>\n<h3>\u516d\u3001\u751f\u4ea7\u4f18\u5316&#xff1a;Session \u5171\u4eab&#xff08;\u96c6\u7fa4\u90e8\u7f72&#xff09;<\/h3>\n<p>\u5355\u673a Session \u5b58\u5185\u5b58\u6ca1\u95ee\u9898&#xff0c;\u4f46\u591a\u5b9e\u4f8b\u90e8\u7f72\u65f6\u4f1a\u4e22\u5931\u4f1a\u8bdd&#xff01;<\/p>\n<h4>\u89e3\u51b3\u65b9\u6848&#xff1a;\u5c06 Session \u5b58\u5165 Redis<\/h4>\n<ul>\n<li>\u6dfb\u52a0\u4f9d\u8d56&#xff1a;<\/li>\n<\/ul>\n<p>&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;org.springframework.session&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spring-session-data-redis&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<ul>\n<li>\u914d\u7f6e\u542f\u7528&#xff1a;<\/li>\n<\/ul>\n<p>&#064;EnableRedisHttpSession(maxInactiveIntervalInSeconds &#061; 1800)<br \/>\npublic class SessionConfig {}<\/p>\n<ul>\n<li>\u914d\u7f6e Redis \u8fde\u63a5&#xff08;application.yml&#xff09;<\/li>\n<\/ul>\n<p>&#x1f389; \u6b64\u65f6\u6240\u6709\u5b9e\u4f8b\u5171\u4eab Session&#xff0c;\u65e0\u7f1d\u652f\u6301\u6c34\u5e73\u6269\u5c55&#xff01;<\/p>\n<hr \/>\n<h3>\u4e03\u3001Session vs Token&#xff1a;\u5982\u4f55\u9009\u62e9&#xff1f;<\/h3>\n<table>\n<tr>\u7279\u6027SessionJWT\/Token<\/tr>\n<tbody>\n<tr>\n<td>\u72b6\u6001<\/td>\n<td>\u6709\u72b6\u6001&#xff08;\u670d\u52a1\u7aef\u5b58\u50a8&#xff09;<\/td>\n<td>\u65e0\u72b6\u6001<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u57df<\/td>\n<td>\u56f0\u96be&#xff08;Cookie \u9650\u5236&#xff09;<\/td>\n<td>\u5bb9\u6613&#xff08;Header \u4f20\u9012&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5b89\u5168\u6027<\/td>\n<td>\u9ad8&#xff08;\u53ef\u4e3b\u52a8\u9500\u6bc1&#xff09;<\/td>\n<td>\u4f9d\u8d56\u7b7e\u540d&#xff0c;\u65e0\u6cd5\u4e3b\u52a8\u5931\u6548<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u4f20\u7edf Web \u5e94\u7528<\/td>\n<td>\u524d\u540e\u7aef\u5206\u79bb\u3001\u79fb\u52a8\u7aef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4cc;\u00a0\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u5185\u90e8\u7ba1\u7406\u7cfb\u7edf \u2192\u00a0Session<\/li>\n<li>App\/\u5c0f\u7a0b\u5e8f\/H5 \u2192\u00a0Token<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516b\u3001\u7ed3\u8bed<\/h3>\n<p>\u611f\u8c22\u60a8\u7684\u9605\u8bfb&#xff01;\u5982\u679c\u4f60\u6709\u4efb\u4f55\u7591\u95ee\u6216\u60f3\u8981\u5206\u4eab\u7684\u7ecf\u9a8c&#xff0c;\u8bf7\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u4ea4\u6d41&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5b66 Session \u767b\u5f55&#xff1f;\u5728 JWT\u3001OAuth2\u3001Token \u98ce\u9761\u7684\u4eca\u5929&#xff0c;\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u201c\u73b0\u5728\u8fd8\u6709\u4eba\u7528 Session \u5417&#xff1f;\u201d\u7b54\u6848\u662f&#xff1a;\u6709&#xff01;\u800c\u4e14\u5f88\u591a&#xff01;\u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf&#xff08;\u5982 OA\u3001ERP&#xff09;\u4ecd\u5e7f\u6cdb\u4f7f\u7528 Session\u5bf9\u5b89\u5168\u6027\u8981\u6c42\u9ad8\u3001\u9700\u5f3a\u4f1a\u8bdd\u63a7\u5236\u7684\u573a\u666f&#xff08;\u5982\u94f6\u884c\u540e\u53f0&#xff09;\u4e0d\u9700\u8981\u8de8\u57df\u3001\u4e0d\u8ffd\u6c42\u65e0\u72b6\u6001\u7684\u4e2d\u5c0f\u578b We<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,190],"topic":[],"class_list":["post-63455","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/63455.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5b66 Session \u767b\u5f55&#xff1f;\u5728 JWT\u3001OAuth2\u3001Token \u98ce\u9761\u7684\u4eca\u5929&#xff0c;\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u201c\u73b0\u5728\u8fd8\u6709\u4eba\u7528 Session \u5417&#xff1f;\u201d\u7b54\u6848\u662f&#xff1a;\u6709&#xff01;\u800c\u4e14\u5f88\u591a&#xff01;\u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf&#xff08;\u5982 OA\u3001ERP&#xff09;\u4ecd\u5e7f\u6cdb\u4f7f\u7528 Session\u5bf9\u5b89\u5168\u6027\u8981\u6c42\u9ad8\u3001\u9700\u5f3a\u4f1a\u8bdd\u63a7\u5236\u7684\u573a\u666f&#xff08;\u5982\u94f6\u884c\u540e\u53f0&#xff09;\u4e0d\u9700\u8981\u8de8\u57df\u3001\u4e0d\u8ffd\u6c42\u65e0\u72b6\u6001\u7684\u4e2d\u5c0f\u578b We\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/63455.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-21T16:32:35+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63455.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/63455.html\",\"name\":\"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-21T16:32:35+00:00\",\"dateModified\":\"2026-01-21T16:32:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/63455.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/63455.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63455.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/63455.html","og_locale":"zh_CN","og_type":"article","og_title":"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u524d\u8a00&#xff1a;\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5b66 Session \u767b\u5f55&#xff1f;\u5728 JWT\u3001OAuth2\u3001Token \u98ce\u9761\u7684\u4eca\u5929&#xff0c;\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u201c\u73b0\u5728\u8fd8\u6709\u4eba\u7528 Session \u5417&#xff1f;\u201d\u7b54\u6848\u662f&#xff1a;\u6709&#xff01;\u800c\u4e14\u5f88\u591a&#xff01;\u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf&#xff08;\u5982 OA\u3001ERP&#xff09;\u4ecd\u5e7f\u6cdb\u4f7f\u7528 Session\u5bf9\u5b89\u5168\u6027\u8981\u6c42\u9ad8\u3001\u9700\u5f3a\u4f1a\u8bdd\u63a7\u5236\u7684\u573a\u666f&#xff08;\u5982\u94f6\u884c\u540e\u53f0&#xff09;\u4e0d\u9700\u8981\u8de8\u57df\u3001\u4e0d\u8ffd\u6c42\u65e0\u72b6\u6001\u7684\u4e2d\u5c0f\u578b We","og_url":"https:\/\/www.wsisp.com\/helps\/63455.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-21T16:32:35+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/63455.html","url":"https:\/\/www.wsisp.com\/helps\/63455.html","name":"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-21T16:32:35+00:00","dateModified":"2026-01-21T16:32:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/63455.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/63455.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/63455.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u57fa\u4e8eSession\u5b9e\u73b0\u767b\u5f55\u6d41\u7a0b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=63455"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63455\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=63455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=63455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=63455"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=63455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}