Questions tagged [django-sessions]

For questions related to Django's session mechanism.

Django provides full support for anonymous sessions. The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies. Cookies contain a session ID – not the data itself (unless you’re using the cookie based backend or a custom backend).

Reference: https://docs.djangoproject.com/en/stable/topics/http/sessions/

490 questions
0
votes
2 answers

How to set new value for a key in Django Session_data

What I have in my encoded session_data is: 'workspaceKey':'8d7f4b3106c740c1a54970a8b67d156d', '_auth_user_hash': '7e024dd67ccb0e2aaab9ac1a92887109f7f020e4', '_auth_user_id': '1', '_auth_user_backend':…
Roshan Bagdiya
  • 2,048
  • 21
  • 41
0
votes
1 answer

Django user sessions browser quit not ending session

I am using the following library https://github.com/Bouke/django-user-sessions to get the ability to end my session on the fly. When I am quitting the browser(not closing but ending the browser running task) the user session does not end. I tried…
Mihir Kavatkar
  • 111
  • 2
  • 7
0
votes
1 answer

Django SESSION_COOKIE_HTTPONLY set but the HttpOnly flag does not show up on cookies

I've set this variable in the settings file like this: SESSION_COOKIE_HTTPONLY = True but when I open the website with Google Chrome HttpOnly does not show up in set-cookie. My webserver is Apache2.4, and the website is using Https protocol.
Navid777
  • 3,591
  • 8
  • 41
  • 69
0
votes
1 answer

django cache.clear() ending session (logout)

I'm using memcached in Django to cache the entire site. https://docs.djangoproject.com/en/1.11/topics/cache/#the-per-site-cache I've added some code in a post-save signal handler method to clear the cache when certain objects are created or updated…
Martinez Mariano
  • 541
  • 8
  • 19
0
votes
1 answer

Show/hide a link based on checkbox value and saved session

I don't know how to accomplish this. I have this checkbox that when check will show the link and once unchecked will hide the link. $('#chk').click(function(){ if( $(this).is(':checked') ) { $('#link1').show(); } else { …
0
votes
1 answer

Django Error : 'No module named django.sessions'

I'm getting an error in my Django Project and I would like to find a solution. I developped my project with MySQL Database, but after some discussions, I would like to replace MySQL by NoSQL Database (and Django ORM commands by Django MongoDB…
Essex
  • 6,042
  • 11
  • 67
  • 139
0
votes
1 answer

Django cookie setting

I am using Django - ldap authentication in my project . Once if the user is authenticated , i need to set a cookie and return as a response to the server . def post(self,request): userData = json.loads(request.body) username =…
Pravin Bhasker
  • 95
  • 3
  • 13
0
votes
1 answer

django powered website switches between logged in users

I am trying to find the root cause for the following problem with a Django powered website. The problem is: Sporadically, a user that is currently logged into the website, on clicking random links on the website, is automatically switched to a…
venkrao
  • 383
  • 4
  • 17
0
votes
1 answer

Check User online Django 1.10

Hi trying to do like in example: How to check whether a user is online in django template? but when adding 'userprofile.middleware.ActiveUserMiddleware', to MIDDLEWARE_CLASSES recieving next error: Unhandled exception in thread started by…
Hellbea
  • 289
  • 6
  • 14
0
votes
1 answer

Django/Django-CMS Session variables with old values

I've got a site in Django/Django-CMS in which I want to save some data from one page to another. I'm saving the data in the session variable: request.session['yb_name'] = request.POST.get('name') The problem is that sometimes my pages get and old…
patricia
  • 1,075
  • 1
  • 16
  • 44
0
votes
1 answer

Django- Session Variables in user_passes_test

I'd like to run method decorator @user_passes_test and use a session variable in that test: def has_correct_search(user): source = request.session['source'] if ApiSearch.objects.filter(user=user, source=source).exists(): return True …
Adam Starrh
  • 6,428
  • 8
  • 50
  • 89
0
votes
2 answers

Setting the value of a model field based on user authentication in Django

I'm trying to selectively process a field in my Django/Python application based on whether a user is logged in or not. Basically, I have a model similar to the following: class Resource(models.Model): uploaded = models.DateTimeField() name =…
Faisal
  • 297
  • 2
  • 16
0
votes
0 answers

Django Cookie is not set properly

I am trying to set a cookie in a Django view. Something like this: def my_view(request): response = HttpResponse('Setting a cookie') if 'my_cookie' in request.COOKIES: return HttpResponse('Cookie found.') else: …
darkhorse
  • 8,192
  • 21
  • 72
  • 148
0
votes
0 answers

Django: How can I store session data in unit test?

This is part of my views.py views,py . . def get(self, request, *args, **kwargs): if request.session['from_product'] = True: blah blah . . For passing this if statement, I tried to store session data in test code like this: class…
user3595632
  • 5,380
  • 10
  • 55
  • 111
0
votes
0 answers

Store boto3 session object in Django Session

I am trying to store boto3 session object in Django session so that I can reuse that same object as long Django session is available. This saves Auth requests for each operation I perform using boto3. boto3_session =…
Mudasir Mirza
  • 171
  • 3
  • 13