Javascript 如何防止来自外部站点的会话超时?

Javascript 如何防止来自外部站点的会话超时?,javascript,python,node.js,Javascript,Python,Node.js,我正在使用nodeJS创建一个应用程序,以创建我们学院学生门户的简化体验,该门户使用基于会话的身份验证。我知道在python中,我们有请求模块,从中,我们可以使用requests.Session()对象从同一个会话发出get、post等请求。NodeJS与此等价的是什么 此外,门户设置为在15分钟不活动后结束会话。我可以做些什么来避免这种情况,例如生成一个永不结束的会话吗?找到了解决方案。 我使用axios发出请求 const axios = require("axios")

我正在使用nodeJS创建一个应用程序,以创建我们学院学生门户的简化体验,该门户使用基于会话的身份验证。我知道在python中,我们有
请求
模块,从中,我们可以使用
requests.Session()
对象从同一个会话发出get、post等请求。NodeJS与此等价的是什么

此外,门户设置为在15分钟不活动后结束会话。我可以做些什么来避免这种情况,例如生成一个永不结束的会话吗?

找到了解决方案。 我使用axios发出请求

const axios = require("axios");
const axiosCookieJarSupport = require("axios-cookiejar-support").default;
const tough = require("tough-cookie");
axiosCookieJarSupport(axios);
const cookieJar = new tough.CookieJar();
axios.get(url, {
    jar: cookieJar,
    withCredentials: true,
  }).then((res)=>{
    //do your stuff
    //any set-cookie headers will be automatically processed.
    //use the same config for further requests, 
    //it will automatically send the cookies alongside the requests.
  })

找到了解决办法。 我使用axios发出请求

const axios = require("axios");
const axiosCookieJarSupport = require("axios-cookiejar-support").default;
const tough = require("tough-cookie");
axiosCookieJarSupport(axios);
const cookieJar = new tough.CookieJar();
axios.get(url, {
    jar: cookieJar,
    withCredentials: true,
  }).then((res)=>{
    //do your stuff
    //any set-cookie headers will be automatically processed.
    //use the same config for further requests, 
    //it will automatically send the cookies alongside the requests.
  })


如果您使用express,您可以在NPM查看
express session
软件包。如果您使用express,您可以在NPM查看
express session
软件包。