-
-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
In Express Session Every Time new session id is generated on ajax call #520
Comments
Hi @brijeshIOGit sorry your issue hasn't gotten to yet. Thanks for the server code! Is it possible you can provide the client side code that demonstrates the issue? Nothing seems wrong in your server example, so not sure what is happening. Ideally can you provide the following:
Thanks! |
Any ajax call from from front end to session api will create new session id. You can check by hitting session api using ajax call.You will the exact problem if you print the session ID returned by api.
|
Hi @brijeshIOGit I use this module on my own servers and of course use AJAX calls to the server (because, single page apps) and never have an issue. I'm not really sure what is going on with your setup, through. I'd be happy to take a look 👍 Ideally can you provide the following:
Thanks! |
@dougwilson I have the same issue from my AngularJS client. I am running my server with Node v6.11.3, express-session 1.15.6 |
Hi @naz-mul very sorry you're experiencing this issue :( No one has provided me the information I need to start looking into it yet. Would you be able to? I would love to get to the bottom of this 👍 |
Hi, I have been facing this issue for quite a long time now and it has had me stumped,following are more details: NodeJS 4.5 To check if the user is logged in we have the following common check executed on each route of the application: Server code:
Here is the flow of the issue
Steps 4 to 8 continue in a loop when the user tries to login again. Note that on the forced logout at step 7 below is the code:
Following is the client side code of how we are forcing the logout on AJAX call
From analysis it seems to be related to a possible race condition because Memory store is being used for the session but haven't been able to confirm this nor find a resolution for it Any help here is appreciated |
Hi @ricfernandes thanks for the additional information. I'm trying to setup a server and client what that code but not sure how to get it pieced together to be functional in order to be able to run it with a debugger to help see what is going on. Can you provide instructions for how to set it all up and the step by step instructions to reproduce the issue? |
Hi @dougwilson , Apologies for the long wait, following is a sample skeleton of the code for the usecase:
The steps for the issue are mentioned in my previous post, the only difference is the login with SSO is replaced by a simulation of it with user just getting logged in on hitting /# Hopefully this will help Thanks |
Hi @dougwilson , Just wanted to check if you have had a chance to test out the sample code provided. Thanks |
I haven't yet, very sorry. I have it on my todo unless someone else is able to figure it out before hand. |
Ok, so I just downloaded, installed, and setup the app. I loaded the /# and clicked on the AJAX link. Everything seems good. Didn't realize that I actually needed to do this were I would have at least an hour to reproduce the issue (and then an hour each time to try again...?) so I didn't choose a good time, so if I really need to keep it open for an hour, I may not be able to have it left open that long during this session. |
I can say, though, that looking at the cookie that your server set in the web browser, it is set to expire after 1 hour. So... is this your issue? Once the cookie expires, the web browser won't sent in in the request, so if you just leave the app past the cookie expiration time, you'll get a new session. |
@dougwilson , yes the cookie is set to expire after an hour. Adding back the steps sed to reproduce this for reference:
Steps 4 to 8 continue in a loop when the user tries to login again. As noted in step 6, after the re-login the first landing page does not have any issue with verifying that the session is active and loads successfully. however the AJAX request that is triggered from the landing page is not able to detect the same session, in fact it ends up with a different session id |
Thanks for the information! I'll try to start this again sometime this week or next if I know I have at least an hour to spend on it, though I have no guarantees. Absolutely would accept a PR with a fix; though 👍 |
@ricfernandes / @dougwilson did either of you get any further with this? I'm hitting the same issue: Node version: v8.11.3 client side code
server side
output TEST: UV2UwbDwcobDEhv0E4SNUyR2ldYyzu8C |
I'm sorry I have not and honestly completely forgot about this. I'll try to find some time, but ultimately the best way to get moving is if you're able to make a pull request with a fix, of course ❤️ |
Actually (for my situation at least) I've come across a solution for this right after I posted lol updated below:
So (with fetch at least) it doesn't send cookies by default, you need to set credentials to "same-origin". This kicks the express-session into gear to use the correct session for the request. @brijeshIOGit / @ricfernandes not sure if this helps? Maybe double check the request is actually sending the HTTP cookie header. |
Thanks @ottis ! I'm going to close this since we have a solution 🎉 |
I am Using expression-session and express-mysql-session for storing in database but on every ajax returns new session id.For more info calling from http only.This issue is not coming when i disable security of browser.``
My Code is
The text was updated successfully, but these errors were encountered: