alexedwards / scs

HTTP Session Management for Go
MIT License
2.02k stars 165 forks source link

sqlite3 store with custom table name #209

Open W1M0R opened 1 month ago

W1M0R commented 1 month ago

Currently, sqlite3store requires an sqlite table named "sessions", as per the documentation and source code here:

  1. https://github.com/alexedwards/scs/blob/master/sqlite3store/README.md
  2. https://github.com/alexedwards/scs/blob/master/sqlite3store/sqlite3store.go

Imagine a scenario where I want to use two session managers, as described here (https://github.com/alexedwards/scs?tab=readme-ov-file#multiple-sessions-per-request), each with their own separate sqlite3 stores and cookie settings. I'm not sure what would happen if both session managers use the same "sessions" sqlite3 table, but I'm guessing everything will actually work as expected, that is, all tokens will expire at the right time (according to their session manager options) and there won't be any strange side-effects.

Ideally though, I'd like to be able to specify the table used by the stores, e.g. "sessions_auth", and "sessions_opts". In that way, I could provide tables that match my schema naming conventions. I'm not sure if there are other good reasons for wanting to specify the table name.

If I want to enumerate (or clear/delete) all the sessions managed by manager 1, but keep the sessions of manager 2 unchanged, would this be possible with the current shared "sessions" table?