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 8535569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:27:45+00:00 2026-06-11T10:27:45+00:00

I’m having trouble with passport.js using the local strategy. I have 2 specific problems:

  • 0

I’m having trouble with passport.js using the local strategy. I have 2 specific problems:

  1. I am not getting persistent sessions to work with example code (see
    below) for the most basic case.
  2. I want to go sessionless. For the
    most basic case, on login, I’ll pass in a username + password that
    provides me with a session token, on regular requests I’ll use this
    session token hashed with some other stuff to authenticate. Is this
    easily done with passport? It seems like passport doesn’t offer much in this case and that cooking up my own solution is easier- just login/logout with standard checks, and then a middleware that unhashes request tokens to verify requests. Easy cheezy?

Problem 1:

Using the reference code from the library:

https://github.com/jaredhanson/passport-local/blob/master/examples/login/app.js

I do a series of commands to show logged out vs logged in:

A. check /account, not logged in

curl -v localhost:3000/account

As expected I get a redirect to /login

<p>Moved Temporarily. Redirecting to <a href="http://localhost:9292/login">http://localhost:3000/login</a></p>

B. login

curl -v -d "username=bob&password=secret" http://127.0.0.1:3000/login

Also as expected, I get a redirect to /

<p>Moved Temporarily. Redirecting to <a href="http://127.0.0.1:3000/">http://127.0.0.1:3000/</a></p>

C. check /account, logged in

curl -v localhost:3000/account

What the hell???

<p>Moved Temporarily. Redirecting to <a href="http://localhost:9292/login">http://localhost:3000/login</a></p>
  • 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-11T10:27:47+00:00Added an answer on June 11, 2026 at 10:27 am

    In the case of 1, session support requires cookies to be configured on your server side and used by your user agent. Typically this is a browser, which will will transmit the cookies in each request, and the server uses them to restore your login state.

    However, the curl commands you are using won’t transmit cookies, so each request looks “new” to the server, which is why you see the redirect to login each time. I suspect if you try the same requests in a browser, this will work as expected.

    As for 2, I’d need a few more details to suggest a good solution. If you are using HTML and web browsers to access your site, you’re going to end up needing something like sessions. You could transmit this info in query parameters each time, rather than cookies, but you’ll end up rebuilding a lot of what Express/Connect provides out of the box.

    In any case, if you choose to go down that route, Passport provides a clean interface to implement your own authentication strategies. You’ll simply need to parse the request for the relevant credentials and look up a user in your database.

    API clients are different, and I’d suggest taking a look at Passport’s OAuth support, which provides easy ways to authenticate access tokens that are associated with a specific client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.