Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:27:50+00:00 2026-06-15T04:27:50+00:00

I have a custom session class that I’ve built to extend the Django SessionBase.

  • 0

I have a custom session class that I’ve built to extend the Django SessionBase. I did this in order to reuse a legacy Session table, so that sessions can pass between our Django pages and our PHP pages without having the user to log in and back out.

Everything’s working perfectly so, far with one huge BUT.

I wrote some custom middleware in order to let the SessionStore.start() function have access to the Request Object. Unfortunately, in order to do that I used this answer: Access request.session from backend.get_user in order to remedy my problem.

I have learned that using the above answer (Essentially binding the request object to the settings, so you can access using import settings* and then settings.request) is totally horrible and the absolutely worst way to do this.

My core problem, is I don’t understand how I can access the request from within the custom session backend I’ve written.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:27:52+00:00Added an answer on June 15, 2026 at 4:27 am

    Django’s SessionMiddleware does this:

    class SessionMiddleware(object):
        def process_request(self, request):
            engine = import_module(settings.SESSION_ENGINE)
            session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
            request.session = engine.SessionStore(session_key)
    

    can’t you do this?

    import mycustomsessionbackend as myengine
    
    class MyCustomSessionMiddleware(object):
        def process_request(self, request):
            session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
            request.session = myengine.SessionStore(session_key, request)
    
    ...
    
    # mycustomsessionbackend.py
    class SessionStore(SessionBase):
        def __init__(self, session_key=None, request=None):
            super(SessionStore, self).__init__(session_key)
            self.request = request
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a custom SessionStoreProvider class that inherits from the SessionStateStoreProviderBase. I have
I currently have a custom session handler class which simply builds on php's session
I have this route that let me build custom url for users like /thisismyname,
I have this custom model, with some methods in it: class GenericModel < ActiveRecord::Base
My scenario is this: I have a custom RavenDB membership provider that is implemented
I have this application that uses custom methods to register and loggin users using
I have custom UITableViewCell . It contains UITextLabel . When I press this cell
I have custom validation rule: public function customRule($check) { } Inside this rule I
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.