I’m using the jquery-cookie module to set/get cookies from jquery.
When I set a cookie – it is a session cookie and I can see it in Chrome’s resources tab.
On the other hand, setting a cookie in Django using reqeust.session[‘mycookie’] = ‘value’ is also a session cookie but it is not visible in Chrome’s resources tab.
Is there a way to use jquery to access or set django session cookies?
This:
is not true.
The session is an object stored in the session store, which is usually a database table on your Django server. It stores multiple values for a single session key. It is only this session key which exists as a cookie. This obviously has the dual advantages of security and removing the need to transfer a potentially huge cookie on every request.
You may be able to access the session key from jQuery, but this won’t do you any good without access to the session store on the server.
If you really need to do this, you can set actual cookies from Django by using
response.set_cookie– but think carefully about the security and performance implications of doing so.