SessionProviderService Provider. This provider needs to be between the
RouteProvider. For Masonite 1.5+, this provider is already available for you.
memorydriver. This means that all session data is stored in an instantiated object when the server starts and is destroyed when the server stops. This is not good when using a WSGI server like Gunicorn which might use multiple workers because each worker will create it's own memory state and requests may jump from worker to worker unpredictably. If you are only using 1 worker then this won't be an issue as long as the worker doesn't die and reset for the duration of the server's life. In this case you should use another driver that doesn't have the memory issue like the
cookiedriver which will store all session information as cookies instead of in memory.
Sessionkey. So you may access the
Sessionclass in any part of code that is resolved by the container. These include controllers, drivers, middleware etc:
setmethod. If you are using the
memorydriver, it will connect the current user's IP address to the data. If you are using the
cookiethen it will simply set a cookie with a
s_prefix to notify that it is a session and allows better handling of session cookies compared to other cookies.
cookiedriver, the cookie will automatically be deleted after 2 seconds of being set.
SessionManagerkey from the container:
session()function inside your templates (more about templates below).
SessionProvidercomes with a helper method that is automatically injected into all templates. You can use the session helper just like you would use the
config/session.pyfile. It will not point to the correct driver when it is changed using the
SessionManagerclass. If you need to use other drivers, consider passing in a new function method through your view or changing the driver value inside