Skip to content

Session stored globally per request

James Edwards-Jones requested to merge jej/session-stored-globaly into master

What

ApplicationController stores the session so it can be globally accessible per request, in a similar way to how we can access other data stores (redis/postgres) from anywhere.

  • Session.current can be used to access the session, and is cleaned up after the request ends.
  • NamespacedSessionStore can be used to store data under a given key.
  • DynamicStore provides flexibility for setting / retrieving data outside of a web request via a Hash

Why

Used from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/10034 where the alternative might have been to pass session data around with the user. This is cleaner and can be reused for other things.

Conformity

Performance and testing

Edited by Dmytro Zaporozhets (DZ)

Merge request reports