Opened 3 years ago

Closed 3 years ago

#32952 closed Bug (invalid)

Django is not generating new session

Reported by: Inexpli Owned by: nobody
Component: contrib.sessions Version: 3.2
Severity: Normal Keywords: session, cookies
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While i was creating shopping cart which depends on sessionid included in cookie files I once removed sessionid in my browser to test something and then i realised that django don't want to recreate new one. I was looking for solution in internet but i didn't found any equal problem to my and solution to it.

By looking on the django docs. i wrote to setting.py hoping that it would help:

SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'

SESSION_COOKIE_HTTPONLY = True

but still sessionid in cookies doesn't occur.

I read post that sessionid should be generated by django while there is request which require sessionid, and it would be in my situation solution on this problem but in the context_processors.py I wrote that i require sessionid globally:

def basket(request):
    try:
        customer = request.user.customer
    except:
        device = request.COOKIES['sessionid']

        customer, created = Customer.objects.get_or_create(device=device)

    order, created = Order.objects.get_or_create(
        customer=customer, complete=False)

    return {
        'order': order,
    }

And beacouse of the context_processors sends request for sessionid and it can't get one, this error occurs:
https://i.stack.imgur.com/D3d9U.png

Change History (2)

comment:1 by Inexpli, 3 years ago

Summary: Since i removed sessionid in browser cookies, django is not creating new oneDjango is not generating new session

comment:2 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

Note: See TracTickets for help on using tickets.
Back to Top