{"id":4163,"date":"2026-03-26T07:45:24","date_gmt":"2026-03-26T00:45:24","guid":{"rendered":"https:\/\/portal-atlasx.cdg.co.th\/home\/?post_type=docs&#038;p=4163"},"modified":"2026-03-27T08:45:15","modified_gmt":"2026-03-27T01:45:15","slug":"session-based-authentication","status":"publish","type":"docs","link":"https:\/\/portal-atlasx.cdg.co.th\/home\/docs\/axws\/fundamentals\/session-based-authentication\/","title":{"rendered":"Session-Based authentication"},"content":{"rendered":"\n\n\n<p>\u0e40\u0e14\u0e34\u0e21\u0e17\u0e35\u0e41\u0e2d\u0e1b\u0e1e\u0e25\u0e34\u0e40\u0e04\u0e0a\u0e31\u0e19\u0e02\u0e2d\u0e07\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49 JWT (JSON Web Token) \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e22\u0e37\u0e19\u0e22\u0e31\u0e19\u0e15\u0e31\u0e27\u0e15\u0e19 \u0e42\u0e14\u0e22\u0e08\u0e30\u0e41\u0e1a\u0e48\u0e07\u0e40\u0e1b\u0e47\u0e19 <strong>Access Token<\/strong> \u0e41\u0e25\u0e30 <strong>Refresh Token<\/strong> \u0e0b\u0e36\u0e48\u0e07\u0e08\u0e30\u0e16\u0e39\u0e01\u0e2a\u0e48\u0e07\u0e44\u0e1b\u0e43\u0e2b\u0e49\u0e1d\u0e31\u0e48\u0e07 Client \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e01\u0e47\u0e1a\u0e44\u0e27\u0e49\u0e43\u0e19 <strong>Local Storage<\/strong> \u0e02\u0e2d\u0e07\u0e40\u0e1a\u0e23\u0e32\u0e27\u0e4c\u0e40\u0e0b\u0e2d\u0e23\u0e4c<\/p>\n\n\n\n<p>\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e04\u0e27\u0e32\u0e21\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e41\u0e25\u0e30\u0e25\u0e14\u0e04\u0e27\u0e32\u0e21\u0e40\u0e2a\u0e35\u0e48\u0e22\u0e07\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e42\u0e08\u0e21\u0e15\u0e35\u0e41\u0e1a\u0e1a XSS (Cross-Site Scripting) \u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e23\u0e30\u0e1a\u0e1a\u0e21\u0e32\u0e43\u0e0a\u0e49 <strong>Session-based Authentication<\/strong> \u0e41\u0e17\u0e19 \u0e42\u0e14\u0e22\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 session \u0e08\u0e30\u0e16\u0e39\u0e01\u0e40\u0e01\u0e47\u0e1a\u0e43\u0e19 <strong>HTTP-only Cookie<\/strong> \u0e0b\u0e36\u0e48\u0e07\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e1b\u0e49\u0e2d\u0e07\u0e01\u0e31\u0e19\u0e44\u0e21\u0e48\u0e43\u0e2b\u0e49\u0e2a\u0e04\u0e23\u0e34\u0e1b\u0e15\u0e4c\u0e1d\u0e31\u0e48\u0e07 Client \u0e40\u0e02\u0e49\u0e32\u0e16\u0e36\u0e07\u0e44\u0e14\u0e49\u0e42\u0e14\u0e22\u0e15\u0e23\u0e07 \u0e17\u0e33\u0e43\u0e2b\u0e49\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 session \u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e21\u0e32\u0e01\u0e02\u0e36\u0e49\u0e19<\/p>\n\n\n\n<p>\u0e2a\u0e23\u0e38\u0e1b\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e41\u0e1b\u0e25\u0e07\u0e2a\u0e33\u0e04\u0e31\u0e0d:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e40\u0e25\u0e34\u0e01\u0e43\u0e0a\u0e49 JWT token \u0e43\u0e19 Local Storage<\/li>\n\n\n\n<li>\u0e43\u0e0a\u0e49 session-based authentication \u0e41\u0e17\u0e19<\/li>\n\n\n\n<li>\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 session \u0e16\u0e39\u0e01\u0e40\u0e01\u0e47\u0e1a\u0e43\u0e19 HTTP-only Cookie<br><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Registration<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. \u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 Authentication Schema<\/strong><\/h3>\n\n\n\n<p>\u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 Schema session \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 Policy-base \u0e40\u0e02\u0e49\u0e32\u0e16\u0e36\u0e07 session \u0e41\u0e25\u0e30\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e44\u0e14\u0e49<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-Fira-Code\" style=\"font-size:.875rem;font-family:Code-Pro-Fira-Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>builder.Services.AddAuth(builder.Configuration);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddAuth<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 Cache<\/strong><\/h3>\n\n\n\n<p>\u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 <strong>Cache<\/strong> \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e08\u0e31\u0e14\u0e40\u0e01\u0e47\u0e1a Session \u0e25\u0e07 cache \u0e40\u0e1e\u0e37\u0e48\u0e2d performance \u0e43\u0e19\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c \u0e42\u0e14\u0e22 defaul \u0e08\u0e30\u0e43\u0e0a\u0e49 <strong>IDistributedCache<\/strong> \u0e43\u0e19\u0e01\u0e32\u0e23\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e41\u0e25\u0e30\u0e08\u0e31\u0e14\u0e40\u0e01\u0e47\u0e1a Session \u0e0b\u0e36\u0e48\u0e07\u0e08\u0e30\u0e40\u0e01\u0e47\u0e1a Session \u0e43\u0e19 Memory instance \u0e02\u0e2d\u0e07 service \u0e17\u0e35\u0e48\u0e23\u0e31\u0e19\u0e2d\u0e22\u0e39\u0e48 \u0e41\u0e15\u0e48\u0e2b\u0e32\u0e01 \u0e40\u0e1b\u0e47\u0e19 microservices \u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e2a\u0e48 connection redis \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e0a\u0e49 redis \u0e41\u0e17\u0e19\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e01\u0e31\u0e1a\u0e2a\u0e16\u0e32\u0e19\u0e01\u0e32\u0e23\u0e13\u0e4c\u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13  <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-Fira-Code\" style=\"font-size:.875rem;font-family:Code-Pro-Fira-Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ Program.cs\nbuilder.Services.AddCache(builder.Configuration.GetSection(\"Redis\")&#91;\"ConnectionString\"&#93;);\n\n\/\/ AddCache\npublic static IServiceCollection AddCache(this IServiceCollection services, string? connectionString)\n{\n    if (string.IsNullOrEmpty(connectionString))\n    {\n        services.AddDistributedMemoryCache();\n    }\n    else\n    {\n        services.AddStackExchangeRedisCache(option =>\n        {\n            option.Configuration = connectionString;\n        });\n    }\n\n    return services;\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ Program.cs<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddCache<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">GetSection<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Redis&quot;<\/span><span style=\"color: #D4D4D4\">)&#91;<\/span><span style=\"color: #CE9178\">&quot;ConnectionString&quot;<\/span><span style=\"color: #D4D4D4\">&#93;);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ AddCache<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">static<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">IServiceCollection<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">AddCache<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #569CD6\">this<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">IServiceCollection<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">services<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #569CD6\">string<\/span><span style=\"color: #D4D4D4\">? <\/span><span style=\"color: #9CDCFE\">connectionString<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #569CD6\">string<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">IsNullOrEmpty<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">connectionString<\/span><span style=\"color: #D4D4D4\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddDistributedMemoryCache<\/span><span style=\"color: #D4D4D4\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">else<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddStackExchangeRedisCache<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">option<\/span><span style=\"color: #D4D4D4\"> =&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #9CDCFE\">option<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #9CDCFE\">connectionString<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        });<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">services<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 SessionService<\/strong><\/h3>\n\n\n\n<p>\u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 <strong>SessionService<\/strong> \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 Session \u0e02\u0e2d\u0e07 user<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-Fira-Code\" style=\"font-size:.875rem;font-family:Code-Pro-Fira-Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>builder.Services.AddScoped&lt;SessionService>();<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddScoped<\/span><span style=\"color: #D4D4D4\">&lt;<\/span><span style=\"color: #4EC9B0\">SessionService<\/span><span style=\"color: #D4D4D4\">&gt;();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19<\/strong><\/h2>\n\n\n\n<p>\u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19 inject&nbsp;<code>SessionService<\/code>&nbsp;\u0e40\u0e02\u0e49\u0e32 class \u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e1c\u0e48\u0e32\u0e19 constructor<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-Fira-Code\" style=\"font-size:.875rem;font-family:Code-Pro-Fira-Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>public class MyService\n{\n    private readonly SessionService _session;\n\n    public MyService(SessionService session)\n    {\n        _session = session;\n    }\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">MyService<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">private<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">readonly<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">SessionService<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">_session<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">MyService<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #4EC9B0\">SessionService<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">session<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">_session<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #9CDCFE\">session<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Methods<\/h3>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Name<\/strong><\/td><td><strong>Returns<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td><code>CreateSession(String, SessionData, TimeSpan)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e2a\u0e23\u0e49\u0e32\u0e07 session \u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e25\u0e07\u0e43\u0e19 cache<\/td><\/tr><tr><td><code>GetSession(String)<\/code><\/td><td><code>SessionData?<\/code><\/td><td>\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 session \u0e08\u0e32\u0e01 sessionId<\/td><\/tr><tr><td><code>RefreshSession(String, SessionData, TimeSpan)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e2d\u0e31\u0e1b\u0e40\u0e14\u0e15\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e25\u0e30\u0e15\u0e48\u0e2d\u0e2d\u0e32\u0e22\u0e38 session<\/td><\/tr><tr><td><code>RemoveSession(String)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e25\u0e1a session \u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01 cache<\/td><\/tr><tr><td><code>RotateSession(String, SessionData, TimeSpan, TimeSpan)<\/code><\/td><td><code>string?<\/code><\/td><td>\u0e2a\u0e23\u0e49\u0e32\u0e07 session \u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01\u0e15\u0e31\u0e27\u0e40\u0e14\u0e34\u0e21<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Session Data<\/h3>\n\n\n\n<p>\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e43\u0e19 session \u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e14\u0e49\u0e27\u0e22<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Field<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td><code>UserId<\/code><\/td><td>ID \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49<\/td><\/tr><tr><td><code>Role<\/code><\/td><td>\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23 role \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49<\/td><\/tr><tr><td><code>Permission<\/code><\/td><td>\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23 permission \u0e43\u0e19\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a&nbsp;<code>roleId:functionId = view,edit<\/code><\/td><\/tr><tr><td><code>ExpiresAt<\/code><\/td><td>\u0e40\u0e27\u0e25\u0e32\u0e2b\u0e21\u0e14\u0e2d\u0e32\u0e22\u0e38\u0e02\u0e2d\u0e07 session<\/td><\/tr><tr><td><code>IsRotated<\/code><\/td><td>\u0e1a\u0e2d\u0e01\u0e27\u0e48\u0e32 session \u0e19\u0e35\u0e49\u0e16\u0e39\u0e01 rotate \u0e44\u0e1b\u0e41\u0e25\u0e49\u0e27\u0e2b\u0e23\u0e37\u0e2d\u0e22\u0e31\u0e07<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"featured_media":0,"parent":1181,"menu_order":5,"comment_status":"open","ping_status":"closed","template":"","meta":{"nav_title":"","positive":"","negative":"","footnotes":""},"docs_category":[32],"class_list":["post-4163","docs","type-docs","status-publish","hentry","docs_category-frameworks"],"_links":{"self":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/4163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/comments?post=4163"}],"version-history":[{"count":8,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/4163\/revisions"}],"predecessor-version":[{"id":4219,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/4163\/revisions\/4219"}],"up":[{"embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/1181"}],"wp:attachment":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/media?parent=4163"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs_category?post=4163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}