So I'm working with django python, and on every new browser I get a new sessionid for my cookie, every sessionid got a unique session database itself. I'm looking for a way to grab data from other sessionid's if possible.
Example: Im on my site, in 2 different browsers.
Each browser got a unique sessionid cookie, therefore a unique session database.
(cookie examples (not real or valid)):
Chrome: a7363dc Firefox: a3621bcz
In chrome, I got request.session["foo"] Set too "bar"
In Firebox, I got request.session["foo"] set too "zoo"
Is there a way I can like var = request.session[a3621bcz]['foo'] so it takes the value of session "foo" in firefox? (lets say i perform this in chrome)
Or alternatively, is there any way I can make every sessionid cookie the same all the time for everybody? so that everyone has the same access to the request.session["elm"] elements?
Like example: wether im on chrome, firefox, or even at starbucks on my chromebook, when I search for the request.session['foo'] it returns "bar" no matter which one im logging in from?
You can access the sessions of a given session id with:
from django.conf import settings
from importlib import import_module
engine = import_module(settings.SESSION_ENGINE)
sessionstore = engine.SessionStore
session = sessionstore(session_key)
with session_key the session key (so here 'a3621bcz'). You thus can then access it with session['foo']. That being said, it is probably better not to mix sessions. Django makes use of session middleware to make accessing the relevant session more convenient, and thus prevent "leaking" sessions variables between two sessions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With