V
V
Vampre2018-06-11 04:11:25
JavaScript
Vampre, 2018-06-11 04:11:25

Is django session available to jQuery?

There is an application for passing the test online. The results of the answers are stored in the session. It is necessary to make it so that, for example, if the user did not pass the test to the end and closed the site and then went back to the start page, it checks whether the last test is finished and if it is not finished, then a window pops up asking if he wants to continue or start a new test.
I planned to make a pop-up window on jQuery, but when using the following code:

<script type="text/javascript">
        if ($.cookie('poll') == null) {
            alert('Не установленно!')
        }
    </script>

Always shows "Not Installed", even if I know for sure that poll is not empty. poll is a dictionary of responses to a test in a django session.
Actually the question is: is it possible to use jQuery to access data in a Django session?

Also it would be desirable to learn in general opinion about such implementation - storage of results of the test in session.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2018-06-11
@planc

https://docs.djangoproject.com/en/2.0/ref/settings...
the default is SESSION_COOKIE_HTTPONLY = True
and this prevents access to the session cookie from js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question