django-sessions

How to separate user login session and admin login session in django

How to separate user login session and admin login session in django Question: I have created small ecommerce website. User can register and login also created custom admin panel for admin which can product add, update and delete. User and Admin both URLS is different. problem is that when user login into website after I’m …

Total answers: 2

Django session variables not saving when back button clicked

Django session variables not saving when back button clicked Question: On my page i am trying to implement a recently viewed section on my home page. The problem is when I append a new item to request.session["recently-viewed"], the item i just viewed gets deleted from the list when i load a new page. The item …

Total answers: 1

Django How to see the session data insted of the object reference

Django How to see the session data insted of the object reference Question: Im trying to start using session in django, Im trying to see the data in my session but im just getting the object reference not the data console: <cart.cart.Cart object at 0x7f6994753160> views.py def cart_view(request): cart = Cart(request) print(cart) if request.user.is_authenticated: return …

Total answers: 3

Django – Consecutive Request Override Session Attribute

Django – Consecutive Request Override Session Attribute Question: I want to generate an invoice for each order, and in some cases, there are two generated invoices for one order. For those cases, the first invoice request fails and I receive a 400 error with "invalid signature" message (as I defined in my view logic), while …

Total answers: 2

cart session in Django

cart session in Django Question: I use the session to create a shopping cart. I have a product model and a model for Variant, which I color and size my products in the Variant model. So that I can have products with different colors and sizes as well as different prices. The shopping cart I …

Total answers: 1

Django – Session expiration renewal

Django – Session expiration renewal Question: I’m struggling with a question about sessions. I wonder how to make a session expire if the user has not tried to connect to the website in a certain period of time (15 days for example). In other words, I would like to renew the expiration date of a …

Total answers: 4

What is the default Django session lifetime and how to change it?

What is the default Django session lifetime and how to change it? Question: I can’t find a setting for the default session lifetime in https://docs.djangoproject.com/en/1.10/ref/settings/. I know this can be changed manually (How to expire Django session in 5minutes?). Asked By: Siegmeyer || Source Answers: The setting you are looking for is SESSION_COOKIE_AGE, the default …

Total answers: 2

How to set sessions timeout in django?

How to set sessions timeout in django? Question: I want to implement login and logout session in my website through which after a set of time the session should expire automatically. And if user logged in then the user could not go back. Asked By: Mandeep Thakur || Source Answers: In your settings.py set https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SESSION_COOKIE_AGE. …

Total answers: 2

session.get_expiry_age() never decreases

session.get_expiry_age() never decreases Question: I set SESSION_COOKIE_AGE to some value in my settings.py and I want to retrieve the time that is left before a session dies by using session.get_expiry_age() from a view. However, it seems the returned value is never changing between different calls (at different times): it stays at SESSION_COOKIE_AGE, meaning the session …

Total answers: 2

Django session key based expiration

Django session key based expiration Question: I’m using Django sessions and I want to set expiry for a particular key. In an AJAX view I’m doing the following request.session[‘a’] = True request.session.set_expiry(604800) Does this set the expiry for that particular key or that session? I’m setting the sessions for other keys in other AJAX views …

Total answers: 2