User session information storage method, device and electronic device

By compressing, encrypting and signing the user session information, generating user login tokens and saving them on the client, the synchronization problem of distributed session storage solutions during cross-cluster access is solved, and a secure and highly available user session is achieved. Information storage and synchronization.

CN113746882BActive Publication Date: 2024-11-26ADVANCED NOVA TECH (SINGAPORE) PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010471414.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-28
Publication Date
2024-11-26
Estimated Expiration
2040-05-28

Smart Images

  • Figure CN113746882B_ABST
    Figure CN113746882B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a method, device and electronic device for storing user session information. The method includes: determining one or more first user session information, performing compression processing on the first user session information to obtain second user session information; encrypting the second user session information using a predetermined encryption method to obtain overall data, using the overall data as carrier data, determining the header data corresponding to the carrier data using a predetermined signing method, and signing the carrier data and the header data to obtain signed data; encrypting the carrier data and the header data respectively to obtain encrypted carrier data and header data, combining the encrypted carrier data, the header data and the signed data into a user login token; sending the user login token to a web client so that the web client saves the user login token in its corresponding local text file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a method, device and electronic device for storing user session information. Background Art

[0002] In the scenario where users access the Internet, for example, when users use a browser to conduct a session with a server, the attributes and configuration information required for the user session will be stored in a session object. By saving this information in the session object, the user's status information can be maintained on the web server so that it can be accessed from the page on any device at any time.

[0003] Existing session information generally uses a distributed cache solution, such as Redis, Tair, etc. to store session information in different servers in the same cluster, so that the session information of multiple cache storage nodes is synchronized in real time. Therefore, when a user accesses different browsers in the same cluster, they can obtain the same session information. Different servers can find the corresponding session information in the distributed storage according to the index sequence information stored in the cookie, thereby ensuring that the user's session can be saved. However, this distributed cache solution has high requirements for synchronization between session information storage nodes. Once synchronization across cluster servers occurs, this distributed session information storage solution will become unreliable, reducing the user experience. Summary of the invention

[0004] The embodiments of the present specification provide a method, device and electronic device for storing user session information to solve the problem that the existing distributed session information storage solution cannot meet the synchronization requirements when cross-cluster web access occurs.

[0005] To solve the above technical problems, the embodiments of this specification are implemented as follows:

[0006] In a first aspect, an embodiment of this specification provides a method for storing user session information, which is applied to a web server, and the method includes:

[0007] Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0008] Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0009] The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data;

[0010] The carrier data and header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, header data and the signed data are combined into a user login token; the user login token is sent to a web client so that the web client saves the user login token in its corresponding local text file.

[0011] In a second aspect, an embodiment of this specification provides a method for storing user session information, which is applied to a web client, and the method includes:

[0012] Receive a user login token sent by the web server, and save the user login token in a local text file corresponding to the web client;

[0013] The user login token is generated by the web server in the following manner:

[0014] Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0015] Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0016] The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data;

[0017] The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the header data and the signature data are combined into a user login token.

[0018] In a third aspect, an embodiment of the present specification provides a user session information storage device, which is applied to a web server, and the device includes:

[0019] A compression module, used to determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0020] An encryption module, used for encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0021] A signing module, used to use the encrypted whole data as carrier data, determine the header data corresponding to the carrier data by using a predetermined signing method, and perform signing processing on the carrier data and the header data to obtain signed data;

[0022] A storage module is used to encrypt the carrier data and header data respectively to obtain encrypted carrier data and header data, and combine the encrypted carrier data, header data and the signed data into a user login token; and send the user login token to a web client so that the web client saves the user login token in its corresponding local text file.

[0023] In a fourth aspect, an embodiment of the present specification provides a user session information storage device, which is applied to a web client, and the device includes:

[0024] A receiving module is used to receive a user login token sent by a web server, and save the user login token in a local text file corresponding to the web client;

[0025] The user login token is generated by the web server in the following manner:

[0026] Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0027] Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0028] The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data;

[0029] The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the header data and the signature data are combined into a user login token.

[0030] In a fifth aspect, an electronic device provided by an embodiment of the present specification includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a user session information storage method in the first aspect described above is implemented.

[0031] In a sixth aspect, an electronic device provided by an embodiment of the present specification includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a user session information storage method in the second aspect described above is implemented.

[0032] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:

[0033] By determining one or more first user session information, compressing the first user session information to obtain the second user session information, wherein the first user session information is the data information generated when the user accesses the web page; encrypting the second user session information using a predetermined encryption method to obtain the encrypted overall data; using the encrypted overall data as carrier data, determining the header data corresponding to the carrier data using a predetermined signing method, and signing the carrier data and the header data to obtain the signed data; encrypting the carrier data and the header data respectively to obtain the encrypted carrier data and the header data, combining the encrypted carrier data, the header data and the signed data into a user login token; sending the user login token to the web client so that the web client saves the user login token in its corresponding local text file. Based on this solution, by saving the user session information in the web client and using the user session information management solution jointly coordinated by the client and the server, when performing cross-cluster web access, the stored user session information can be directly obtained from the cookie file saved by the client, avoiding the problems existing in cross-cluster synchronization, ensuring that the user session information is not tampered with or cracked, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0035] Figure 1 A schematic diagram of the overall system architecture involved in the solution of this specification in an actual application scenario;

[0036] Figure 2 A flowchart of a method for storing user session information provided in an embodiment of this specification;

[0037] Figure 3 A flowchart of another method for storing user session information provided in an embodiment of this specification;

[0038] Figure 4 A schematic diagram of the structure of a user session information storage device provided in an embodiment of this specification;

[0039] Figure 5 A schematic diagram of the structure of another user session information storage device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0041] In the existing distributed session control technology, the session object is distributed and stored in each server in the same cluster, and the index sequence information of the session object is saved in the browser. In this way, when the user jumps between different web pages of the application, the information stored in the session object will not be lost. Different servers can find the corresponding session in the storage according to the index information in the cookie, and the user's session will be saved forever.

[0042] However, this method of maintaining user session information (i.e., session information) in a distributed manner on the server side often places very high demands on synchronization between session data storage nodes in order to ensure the accuracy and consistency of session data. Once long-distance synchronization occurs across computer rooms, cities, continents, etc., this distributed server-side session storage solution becomes unreliable, reducing the user experience.

[0043] The following is a brief introduction to several existing distributed session storage frameworks. The details are as follows:

[0044] (1) Taking Ant Financial's session1, session2, and xsession as an example, by distributing and storing session information in the cache cluster, since these data are in the same or physically adjacent clusters, there is basically no problem with the real-time synchronization of cache node data; so after users log in to the same or adjacent clusters, they can access different business servers, and the business servers can obtain user session information from the cache cluster in real time. However, when a user logs in to a server in a certain cluster and needs to access a server in another remote cluster, this cluster may be cross-national or cross-continental. At this time, relying on the original distributed cache method to synchronize session data becomes unreliable and impractical.

[0045] (2) The SpringSession framework also has the same problem. It can only ensure the synchronization of session data between servers in the same Redis cluster, and still cannot solve the problem of long-distance cross-cluster access.

[0046] (3) The nginx+tomcat framework generally uses the following three methods to save or synchronize sessions. First, use ip_hash to specify a server access for a user request, but this method cannot solve the synchronization problem in cross-cluster scenarios; second, use tomcat to implement session multicast within the cluster to achieve session sharing. This method cannot achieve session synchronization across clusters and will cause significant network congestion; third, add a dedicated session server to the back end of the web server to store user session information. This method still cannot achieve session synchronization across clusters and will cause significant network congestion.

[0047] For the existing distributed session storage framework, in order to solve the session information synchronization problem during cross-cluster web access and ensure that the user's session information is not tampered with or cracked, a user session information storage method needs to be provided.

[0048] Figure 1The schematic diagram of the overall system architecture involved in the scheme of this specification in an actual application scenario. The overall system architecture may include a user client and multiple clusters, wherein the user client may be a web client (such as a browser) or other application client, and each cluster may include multiple business servers, each business server may be considered as a cache storage node for distributed storage and synchronization of the same session information. After the user accesses and logs in to the login server in cluster A through a browser, a session object associated with the browser and the domain name will be generated in the login server, and a series of session information and states generated during the user's access to the browser will be saved in the session object, and the user session information will be encrypted and signed to generate a user login token (token token) containing the user session information, and the token token will be sent to the user's browser, so that the user's browser saves the token token in the browser's cookie file, so that when the user accesses the browser page corresponding to other clusters (such as cluster B), the cookie file carrying the user session information can be sent to the business server in cluster B, so that the session information synchronization across clusters can be achieved, that is, the session information in cluster A is synchronized to cluster B.

[0049] The following uses the scenario involved in the above-mentioned system overall architecture as an example to explain the technical solution of this specification in detail.

[0050] Figure 2 A flowchart of a method for storing user session information provided in an embodiment of this specification, the method may specifically include the following steps:

[0051] In step S210, one or more first user session information is determined, and compression processing is performed on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page.

[0052] In one or more embodiments of the present specification, when a user accesses a backend server corresponding to a web page through a browser, a session object corresponding to the browser and the accessed domain name is generated in the web server. The session object can be considered as a piece of memory opened in the memory of the web server, and the session object is used to record session information. Session information can be considered as a kind of session information, which refers to a series of actions or messages with a beginning and an end. For example, when a user browses a website, the time from the user's access to the website to closing the browser is the time spent by the user browsing the website, and the series of processes during this period can be considered as a session.

[0053] Specifically, in the embodiment of the present specification, the first user session information includes session information stored in a session object, and the first user session information includes user login information, user identity, user login credentials, etc. By compressing the session information generated after the user logs in or accesses the web server, it can be ensured that the data information subsequently stored on the browser side is as small as possible.

[0054] In step S220, the second user session information is encrypted using a predetermined encryption method to obtain encrypted overall data.

[0055] It should be noted that the session information storage in the embodiments of this specification is implemented based on JWT (Json Web Token). JWT is a json format network token specification. JWT includes two implementation methods, namely JWE (Json Web Encryption json, format network encryption specification) and JWS (Json Web Signature, json format network signature specification); among them, the JWE encryption method uses a short string to describe the transmission content, ensuring the security and integrity of the data.

[0056] Further, in the embodiment of the present specification, the compressed session data (i.e., the second user session information) is encrypted by JWE to obtain the encrypted overall data, which includes the third user session information obtained by encrypting the second user session information using the RSA asymmetric algorithm and some additional information, the third user session information is the session information after compression and RSA encryption, and the additional information is used for reverse decryption using JWE after the user obtains the token. The session information will contain a part of the user data, and since these data will be saved in the cookies of the local browser later, the user session information needs to be encrypted to prevent data leakage.

[0057] In step S230, the encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data.

[0058] In one or more embodiments of this specification, the predetermined signing method is the JWS signing method, and the header data is the data generated by the JWS signing method; the JWS signing is a string with a simple unified expression form, which is mainly composed of three parts: header data, carrier data and signing data. The JWS signing can ensure that the data is not modified during the transmission process, thereby verifying the integrity of the data. In actual applications, the JWS signing method uses the HS256 algorithm to perform signing processing on the data merged from the carrier data and the header data (Header data) to obtain the signed data, wherein the header data contains the signing algorithm, custom tags, data version and data type and other contents.

[0059] In step S240, the carrier data and header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, header data and the signed data are combined into a user login token; the user login token is sent to the web client so that the web client saves the user login token in its corresponding local text file.

[0060] In one or more embodiments of the present specification, before the carrier data, header data and signature data are combined to generate a user login token, the carrier data and header data can be encrypted separately using the base64url algorithm to prevent the user from directly intercepting the carrier data from the cookie and obtaining user information after base64url conversion.

[0061] Specifically, in the embodiments of this specification, the user login token is a token, and the local text file is a cookie file; wherein the token is generated on the server side. If the front end (such as the browser side) uses the user name and password to request authentication from the server side, and the server side successfully authenticates, then the server side will return the token to the front end. The front end can bring the token with it in each request to prove its legal status. The token can be considered as a permanent identity token. A cookie file is a "small text file" stored on the client side. It is data (usually encrypted) stored locally by some websites in order to identify the user's identity and conduct session tracking. It is temporarily or permanently stored by the user's client.

[0062] Furthermore, in an embodiment of the present specification, the token generated by the web server can be sent to the web client in the following manner, specifically, by setting a character string corresponding to the token in an http response message (http response), and sending the token to the web client via the http response message, so that the web client saves the token in a cookie file.

[0063] The content of the above embodiment mainly introduces how to store the user's session information from the web server to the web browser, that is, to save the user session information on the user's browser side, rather than just synchronizing the user session information between the servers in the same cluster. The following will be combined with a specific embodiment to explain how to implement the cross-cluster session information synchronization based on this storage method after the token containing the user session information is stored in the browser's cookie file. The specific content is as follows:

[0064] When a user accesses a web page corresponding to another cluster server outside the web server, the cluster server receives a service request sent by the web client. The service request carries a cookie file. The cluster server obtains a token from the cookie file, verifies the token, obtains carrier data from the token after successful verification, decrypts the carrier data, decompresses the decrypted data to obtain the first user session information, and synchronizes the first user session information to the cluster.

[0065] That is to say, when a user accesses a business server in another cluster, the cookie file carrying the token will be passed out, so that the user session information will be passed to the corresponding server after the web page jumps to access other cluster servers. Therefore, other cluster servers that do not store the user session information can directly obtain the token from the cookie, and obtain the complete user session information after parsing and verifying it, thereby realizing the synchronization of user session information across clusters.

[0066] Based on the technical solution in the embodiment of this specification, the user's session information is encrypted and signed based on the JWT protocol, and stored from the server to the user's browser. The server no longer saves the login information. The server generates a token based on the user's session information and stores the token in the local cookie of the browser. When the user accesses other pages across cluster servers, the cookie information containing the token is added to the request header in the user's access request and passed to the servers of other clusters, and the token is verified by other cluster servers. The embodiment of this specification saves the user session information on the client by combining JWT with cookies. The user session information management solution based on the joint cooperation between the client and the server solves the problem that the user session information cannot be obtained from the distributed cache of the cluster when crossing computer rooms, cities, and continents. The session data is encrypted and signed using the JWT format to ensure that the session data is not tampered with or cracked, reducing the synchronization and maintenance costs of the user session information, thereby providing a secure and highly available user session information storage and synchronization solution.

[0067] The above embodiments are described with the web server as the execution subject. The following describes the implementation process of the method for storing user session information in the embodiments of this specification in detail by taking the web client as the execution subject. Figure 3 FIG. 1 is a flow chart of another method for storing user session information provided by an embodiment of this specification. The method may specifically include the following steps:

[0068] In step S310, a user login token sent by the web server is received, and the user login token is saved in a local text file corresponding to the web client;

[0069] The user login token is generated by the web server in the following manner:

[0070] Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0071] Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0072] The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data;

[0073] The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the header data and the signature data are combined into a user login token.

[0074] Since in the implementation process of the entire user session information storage solution, the operation performed by the web client is mainly to save the token sent by the web server. Therefore, when the web client is used as the execution subject, the process of how to generate a token based on session information will not be described. The following are the relevant operations performed by the web client. The implementation process of the web server operation part is the same as that of the aforementioned embodiment, which will not be repeated here.

[0075] Furthermore, in the embodiment of this specification, the user login token is a token token, and the local text file is a cookie file;

[0076] The receiving the user login token sent by the web server and storing the user login token in a local text file corresponding to the web client includes:

[0077] Receive an http response message sent by a web server, wherein the http response message includes a token, and save the token in a cookie file.

[0078] Further, in the embodiment of the present specification, after the user login token is saved in the local text file corresponding to the web client, it also includes:

[0079] When a user accesses a web page corresponding to another cluster server outside the web server, the web client sends a service request to the cluster server, and the service request carries a cookie file, so that the cluster server obtains a token from the cookie file, verifies the token, obtains carrier data from the token after successful verification, decrypts the carrier data, decompresses the decrypted data to obtain the first user session information, and synchronizes the first user session information to the cluster.

[0080] Based on the same idea, the embodiment of this specification also provides a user session information storage device, such as Figure 4 This is a schematic diagram of a user session information storage device provided in an embodiment of this specification. The device is applied to a web server. The device 400 mainly includes:

[0081] A compression module 401 is used to determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0082] The encryption module 402 is used to encrypt the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0083] The signing module 403 is used to use the encrypted whole data as carrier data, determine the header data corresponding to the carrier data by using a predetermined signing method, and perform signing processing on the carrier data and the header data to obtain signed data;

[0084] The storage module 404 is used to encrypt the carrier data and the header data respectively to obtain encrypted carrier data and header data, and combine the encrypted carrier data, header data and the signed data into a user login token; and send the user login token to the web client so that the web client saves the user login token in its corresponding local text file.

[0085] The present specification also provides another user session information storage device, such as Figure 5 This is a schematic diagram of the structure of another user session information storage device provided in an embodiment of this specification. The device is applied to a web client. The device 500 mainly includes:

[0086] The receiving module 501 is used to receive the user login token sent by the web server, and save the user login token in a local text file corresponding to the web client;

[0087] The user login token is generated by the web server in the following manner:

[0088] Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page;

[0089] Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data;

[0090] The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data;

[0091] The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the header data and the signature data are combined into a user login token.

[0092] The embodiment of the present specification also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned user session information storage method when executing the program.

[0093] The embodiment of the present specification also provides another electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned another user session information storage method when executing the program.

[0094] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0095] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0096] The apparatus, electronic device, non-volatile computer storage medium and method provided in the embodiments of this specification correspond to each other, and therefore, the apparatus, electronic device and non-volatile computer storage medium also have similar beneficial technical effects as the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the corresponding apparatus, electronic device and non-volatile computer storage medium will not be repeated here.

[0097] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0098] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0099] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0100] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing one or more embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0101] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may be in the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the embodiments of this specification may be in the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0102] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0103] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0105] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0106] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0107] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0108] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0109] The specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media including storage devices.

[0110] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0111] The above is only an embodiment of this specification and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for storing user session information, applied to a web server, the method comprising: Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page; Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data; The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data; Encrypting the carrier data and the header data to obtain encrypted carrier data and header data respectively, combining the encrypted carrier data, the encrypted header data and the signed data into a user login token; sending the user login token to a web client so that the web client saves the user login token in its corresponding local text file; The storing of the user login token in its corresponding local text file is specifically used for: when the user accesses a web page corresponding to other cluster servers other than the web server, enabling the other cluster servers to obtain the first user session information from the user login token contained in the local text file carried in the service request sent by the web client, and synchronizing the first user session information to the other cluster servers.

2. According to the method of claim 1, the first user session information comprises session information stored in a session object, and the first user session information comprises user login status information, user identity identifier and user login credentials.

3. The method according to claim 1, wherein the predetermined encryption method is a JWE encryption method, and the encrypted overall data includes encrypted third user session information, and the third user session information is obtained by encrypting the second user session information using an RSA asymmetric algorithm.

4. The method according to claim 1, wherein the predetermined signing method is the JWS signing method, and the header data is data generated by the JWS signing method; The method of using a predetermined signing method to sign the carrier data and the header data to obtain the signed data includes: The JWS signing method is used to sign the data formed by combining the carrier data and the header data to obtain signed data, wherein the header data includes a signing algorithm, a custom tag, a data version, and a data type.

5. The method according to claim 1, wherein the user login token is a token token, and the local text file is a cookie file; The sending the user login token to the web client so that the web client saves the user login token in its corresponding local text file includes: The character string corresponding to the token is set in an http response message, and the token is sent to the web client through the http response message, so that the web client saves the token in a cookie file.

6. The method according to claim 5, after the web client saves the user login token in its corresponding local text file, further comprising: When a user accesses a web page corresponding to another cluster server outside the web server, the cluster server receives a service request sent by the web client, the service request carries a cookie file, the cluster server obtains a token from the cookie file, verifies the token, obtains carrier data from the token after successful verification, decrypts the carrier data, decompresses the decrypted data to obtain first user session information, and synchronizes the first user session information to the cluster.

7. A method for storing user session information, applied to a web client, the method comprising: Receive a user login token sent by the web server, and save the user login token in a local text file corresponding to the web client; The storing of the user login token in the local text file corresponding to the web client is specifically used for: when the user accesses a web page corresponding to other cluster servers other than the web server, enabling the other cluster servers to obtain the first user session information from the user login token contained in the local text file carried in the service request sent by the web client, and synchronizing the first user session information to the other cluster servers; The user login token is generated by the web server in the following manner: Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page; Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data; The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data; The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the encrypted header data and the signature data are combined into a user login token.

8. The method according to claim 7, wherein the user login token is a token token, and the local text file is a cookie file; The receiving the user login token sent by the web server and storing the user login token in a local text file corresponding to the web client includes: Receive an http response message sent by a web server, wherein the http response message includes a token, and save the token in a cookie file.

9. The method according to claim 8, after saving the user login token in a local text file corresponding to the web client, further comprises: When a user accesses a web page corresponding to another cluster server outside the web server, the web client sends a service request to the cluster server, and the service request carries a cookie file, so that the cluster server obtains a token from the cookie file, verifies the token, obtains carrier data from the token after successful verification, decrypts the carrier data, decompresses the decrypted data to obtain the first user session information, and synchronizes the first user session information to the cluster.

10. A user session information storage device, applied to a web server, the device comprising: A compression module, used to determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page; An encryption module, used for encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data; A signing module, used to use the encrypted whole data as carrier data, determine the header data corresponding to the carrier data by using a predetermined signing method, and perform signing processing on the carrier data and the header data to obtain signed data; A storage module is used to encrypt the carrier data and the header data to obtain encrypted carrier data and header data, and combine the encrypted carrier data, the encrypted header data and the signed data into a user login token; and send the user login token to the web client so that the web client saves the user login token in its corresponding local text file; The storing of the user login token in its corresponding local text file is specifically used for: when the user accesses a web page corresponding to other cluster servers other than the web server, enabling the other cluster servers to obtain the first user session information from the user login token contained in the local text file carried in the service request sent by the web client, and synchronizing the first user session information to the other cluster servers.

11. The device according to claim 10, wherein the predetermined signing method is a JWS signing method, the header data is data generated by the JWS signing method, and the signing module is further used to: The JWS signing method is used to sign the data formed by combining the carrier data and the header data to obtain signed data, wherein: The header data includes the signing algorithm, custom tags, data version and data type.

12. The device according to claim 10, wherein the user login token is a token token, the local text file is a cookie file, and the storage module is further used for: The character string corresponding to the token is set in an http response message, and the token is sent to the web client through the http response message, so that the web client saves the token in a cookie file.

13. A user session information storage device, applied to a web client, the device comprising: A receiving module, configured to receive a user login token sent by a web server, and save the user login token in a local text file corresponding to a web client; the saving of the user login token in a local text file corresponding to a web client is specifically used for: when a user accesses a web page corresponding to another cluster server other than the web server, enabling the other cluster server to obtain first user session information from the user login token contained in the local text file carried in a service request sent by the web client, and synchronizing the first user session information to the other cluster server; The user login token is generated by the web server in the following manner: Determine one or more first user session information, and perform compression processing on the first user session information to obtain second user session information, wherein the first user session information is data information generated when a user accesses a web page; Encrypting the second user session information using a predetermined encryption method to obtain encrypted overall data; The encrypted whole data is used as carrier data, the header data corresponding to the carrier data is determined by using a predetermined signing method, and the carrier data and the header data are signed to obtain signed data; The carrier data and the header data are encrypted respectively to obtain encrypted carrier data and header data, and the encrypted carrier data, the encrypted header data and the signature data are combined into a user login token.

14. The device according to claim 13, wherein the user login token is a token token, the local text file is a cookie file, and the receiving module is further used for: Receive an http response message sent by a web server, wherein the http response message includes a token, and save the token in a cookie file.

15. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the program.

16. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 7 to 9 when executing the program.