Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

req.session added variables are not saved on mongo session store, nor on the browser #477

Open
mirker21 opened this issue Dec 3, 2023 · 0 comments

Comments

@mirker21
Copy link

mirker21 commented Dec 3, 2023

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

Whenever I try to log in with the correct username and password on the Next.js front end (localhost:3000), in my post request for /login I am supposed to add two properties (.isAuth, and ._id) to my req.session on my Express.js back end (localhost:8080).

At first, these two things seem to be set, at least in /login. If the /login post request returns a 201 status code, the user is supposed to get redirected to the home page, and be able to see their data. However, when I get redirected to my home page, I cannot get any user data from the /user get request because req.session._id and req.session.isAuth don't exist anymore.

When I check my MongoDB session store, the cookies do get stored every time a user logs in and do disappear after expiration, but the info I wanted to store on the 'session' part was not there. When I try to look for any cookies on Chrome Developer Tools, I don't see any.

So far I haven't found a solution that has fixed my problem yet. I have looked at similar past issues on stackoverflow, on the open and closed issues on both express-session and connect-mongo, but nothing really helped so far. I am not sure if this is an express-session issue or a connect-mongo issue, so I posted this issue here, as well as in express-session's Issues section.

  • **Here is the repository with all my current code surrounding this issue. **
  • Setting secure to true, and sameSite to none does nothing.
  • Including credentials in headers, cors middleware, and frontend requests did not do anything.
  • When I look at the secure connection icon when viewing the website on localhost:3000, I get the "Your connection to this site is not secure" warning.
  • Also after the post request, the Chrome Developer Tools sometimes gives an error "Attempted to use a disconnected port".
  • I am on iOS, and am using Chrome to look at my website.
  • I've tried Safari but it gives me the same problem.

If you would like to ask me about further details that I didn't mention that might contribute to this issue, or ask for clarification on anything I didn't explain that well, please don't hesitate!

Thank you all for your time and patience, it is much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant