I have four session variables–
location = request.session['location']
computer = request.session['computer']
phone = request.session['phone']
hobby = request.session['hobby']
I have several view functions that need to use these variables. Is there a way I can store these variables in a separate function and call them from the other functions? If so, how would I do that? Thank you.
Not sure I understand? You can call session variables from wherever the request is available i.e. your views
see more here:
https://docs.djangoproject.com/en/dev/topics/http/sessions/#examples
From your comment:
This function is being passed request as a parameter, and therefore has access to all of request’s variables. One of these variables/objects is session, and this session object in turn has access to the variables you are looking for (username, location etc..). So all you have to do is: