question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access session data inside the template

See original GitHub issue

This library should provide an easy access to session data inside the template similar to Django. I know the workaround (using res.locals) but manually putting data every time in large application really sucks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
joewagnercommented, Jul 24, 2017

@noisytoken that makes sense. Is your current setup basically doing the following?

    app.use(session(options));
    app.use(function (req, res, next) {
        res.locals.session = req.session;
        next();
    });
1reaction
joewagnercommented, Jul 24, 2017

I’d say this is outside the scope of this module, and brittle. @noisytoken what part of “manually putting data every time in large application” sucks? What is your workaround?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django: accessing session variables from within a template?
This answer is for those using Django 3.0 and above · If there's only single data in the session variable, use. {{ request.session.your_session_varaible_name...
Read more >
Accessing session values in templates - Elixir Forum
My question is how do I access the session directly in the template. I was able to find the session value through inspect...
Read more >
Accessing session variables in template with django
Hi All, I am facing issue when I am trying to access session variables in django. I am setting the session variable something...
Read more >
How to access session variables in Twig template?
You can inject new variables into templates by using the appropriate preprocess hook in your theme:
Read more >
Accessing Flask Session Variables in Jinja Templates
In Flask, the session object can be read (in the same manner as a dictionary) to retrieve data unique to the session. It's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found