On May 28, 2017 9:35 AM, <[email protected]> wrote:

Dear Experts, I am new to Django and need your help.

I want a set of variables populated into session variables. These will be
fixed values for the user such as which company he belongs to, his email
id, his role etc.


These values will be read from the database by the login form. These values
need to stay in these variables as long as the user is logged into the
application.


I will be using these variables to decide what data the user can see.


This sounds like a rudimentary permission system. Instead of keeping
permissions in the session, I would suggest using the built-in permissions,
or extending the authorization system using something like Django-guardian.


Question I have is "Will these values be different for each user who is
logged in or are these global to the application and all the users will see
these same values?


Each session is unique to each user. If you need something global to the
system, the session is definitely not the place to put it.

I am using the below code to get the values from the table called "users"
where userroles, companyid are fields in the table

         tFetchData = users.objects.get(emailid = lEmailId)

        request.session['sPassword'] = tFetchData.userroles
        request.session['sCompanyId'] = tFetchData.companyid

This code didn't appear to have anything to do with your question.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciU_E1D2QAT1Nn_ucvkJ3C_5PyLFJ3cbqR%2Br%2BACCOra%2BJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to