Session in the database to solve the lost problem

Source: Internet
Author: User

In programming is the meaning of the conversation
The Session object stores the information that is required for a specific user session. This way, when a user jumps between the application's Web pages, the variables stored in the session object are not lost, but persist throughout the user's session.

When a user requests a Web page from an application, if the user does not yet have a session, the Web server automatically creates a Session object. When the session expires or is discarded, the server terminates the session.

One of the most common uses of Session objects is to store the user's preferences. For example, if a user indicates that they do not like to view a graphic, they can store the information in the Session object. For more information about using session objects, see "Managing Sessions" in the ASP Application section.

**************************

Alas, the previous system session is always inexplicably lost, not in the server process.

is always lost, and then the client quits for no reason. You do not have to set the session time to 1 hours.

Finally helpless, put the session in the database. Ha, the problem is solved.

It took 1 weeks. No customer reflects the problem for the time being.

Maybe everyone's needs are different, but I still feel that the session in the database insurance.


**************************
Can put MONGO also can put redis inside.

It's more than a redis inside.

Node in the express session, we usually put in Redis, and the rest of him to help us automatically manage. Destruction and so on.

*************************

In the Miss Lei Project:

var session = require (' express-session ');

var Redisstore = require (' Connect-redis ') (session);

Store:new redisstore (CONF. Session_redis),

session_redis:{
port:6379,
port:6379,
Host: ' 127.0.0.1 '
Host: ' 10.150.160.136 '
},

Only the IP and port of the database are given.

In the Miss Shen Project:

var session = require (' express-session ');
var Redisstore = require (' Connect-redis ') (session);

Options.store = new Redisstore ({retry_max_delay:5000, max_attempts:3});

Session in the database to solve the lost problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.