bzp2010 commented on issue #12495:
URL: https://github.com/apache/apisix/issues/12495#issuecomment-3229166797

   @RegMTS 
   
   > I've looked through the documentation, but I couldn't find a specific 
example that illustrates how to configure two routes to share a session via 
shdict. To proceed with testing, I would need your help.
   
   This feature is supported by the underlying library `lua-resty-session`. 
While it's already out of the box for the library itself. Unfortunately, APISIX 
currently doesn't directly expose any capability to dynamically configure it.
   Although I believe it's on our to-do list (as some other users have also 
mentioned this need), we currently lack sufficient manpower to complete this 
work, whether from API7.ai engineers or other volunteers in the community.
   
   This doesn't mean we can't configure it at all—there are indeed some 
workarounds available.
   
   1. Directly manipulate the underlying library by setting variables.
   ref: 
https://github.com/bungle/lua-resty-session/blob/v3.10/lib/resty/session.lua#L353
   ref: 
https://github.com/bungle/lua-resty-session/blob/v3.10/lib/resty/session/storage/shm.lua#L23
   
   ```
   nginx_config:
     http_server_configuration_snippet: |
       set $session_storage 'shm';
       set $session_shm_store 'sessions'; # shdict name
   ```
   
   2. Set the name of the shdict used for the session.
   ```
   nginx_config:
     http:
       custom_lua_shared_dict:
         sessions: 100m  # 100MBytes
   ```
   Combine the above configurations.
   
   3. Set the same `session.secret` value across multiple routes.
   
   I think this should work, but I haven't tested it myself yet. So you can 
give it a try. If any issues arise, you can report them here.
   
   (Alternatively, if you prefer, you can also contribute this feature to 
support setting session-related configuration items directly within the plugin 
configuration.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to