P
P
Pavel Dyukarev2018-08-14 20:33:34
Django
Pavel Dyukarev, 2018-08-14 20:33:34

Django and JavaScript throw values ​​in different sessions!?

Guys, help.
I put the value in the session in the Django view: Then I delete this value from the session (I took examples of deletion from here and from here ):
request.session['battary_charge'] = 11

$(document).ready(function () {

    $("#destroy_charge").click(function () {
        //1-ый способ используя jquerySessionPlugin сбрасываем заряд  удаляя ключ battary_charged 
         $.session.remove('battary_charge');
        //2-ой способ используя инструменты HTML5  сбрасываем заряд  удаляя ключ battary_charged 
         sessionStorage.removeItem('battary_charge');
        //проверяю наличие 
        console.log($.session.get('battary_charge'));
        console.log(sessionStorage.removeItem('battary_charge'));
        //перенаправляем на страницу Зарядки+поиска
        window.location.replace("/");
    })
});

The code returns:
undefined
undefined

But when redirecting to another page, the value of request.session['battary_charge'] equal to 11 is still saved. I get: How can this be? Does JS + HTML delete not from the same session that Django uses?
print(request.session['battary_charge'])
11

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question