Session maintenance method and apparatus, electronic device, and storage medium
By storing the session relationship table locally on the client and performing session verification, the security and reliability issues of session persistence between different service systems of the App are resolved, and session persistence and security improvement between multiple modules are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-04
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, apps cannot maintain sessions when switching between different service systems, and distributed session sharing solutions suffer from low security, high risk of single point of failure, storage space abuse, and distrust of third parties.
By storing the session relationship table locally on the client, extracting the target module identifier and session identifier, sending a session verification request to the server, verifying the validity of the session, and feeding back session information when valid, the session is maintained.
It improves session security, avoids security degradation caused by third-party key leakage, solves the problem of storage space abuse, and enables session persistence between multiple modules.
Smart Images

Figure CN116319946B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the communication technology, and particularly to a session maintaining method and device, electronic equipment and storage medium. BACKGROUND
[0002] A mobile application (APP) connects different backend service systems through a unified mobile gateway to provide services to the outside. Different services have different authentication methods, and the APP cannot maintain sessions when switching between different system services.
[0003] In the prior art, in order to solve the problem of session sharing of multiple modules of the APP, a distributed session sharing scheme is mainly used. The distributed session sharing scheme uses a session storage warehouse separated from the APP, and the session information of each module is stored in the session storage warehouse. After a user accesses a session, each module can use a globally unique session identifier to obtain the session information of the user from the session storage warehouse.
[0004] However, the modules in the independent session storage warehouse are coupled together. Once the warehouse key of a certain module is leaked or the independent session storage warehouse has a problem, all modules will be affected, the security is low, and the session maintenance cannot be guaranteed. SUMMARY
[0005] The present application provides a session maintaining method, device, electronic equipment and storage medium to improve the security of the session and realize session maintenance.
[0006] In a first aspect, the embodiments of the present application provide a session maintaining method applied to a client, which comprises:
[0007] After ending the access to the current module, a target module identifier is extracted from an access request in response to an access request to the target module;
[0008] The target module identifier is used to obtain a target session identifier generated in a historical session process of the target module from a session relationship table of the local client;
[0009] According to the target module identifier and the target session identifier, a session verification request is sent to a server corresponding to the target module, and the server performs the following: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determining target session information associated with the target session identifier, and feeding back the target session information to the client;
[0010] Based on the target session information, the target module is continuously accessed.
[0011] In a second aspect, the embodiments of the present application further provide a session maintaining device configured in a client, which comprises:
[0012] The target module identifier extraction module is configured to extract a target module identifier from an access request in response to an access request for a target module after ending access to a current module.
[0013] The target session identifier obtaining module is configured to obtain, using the target module identifier, a target session identifier generated by the target module in a historical session process from a session relationship table of the local client.
[0014] The session verification request sending module is configured to send, to a server corresponding to the target module, a session verification request according to the target module identifier and the target session identifier, and the server is configured to perform the following: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determining target session information associated with the target session identifier, and feeding back the target session information to the client.
[0015] The target module access module is configured to continue to access the target module based on the target session information.
[0016] In a third aspect, an electronic device is provided, and the electronic device includes:
[0017] one or more processors;
[0018] a memory device configured to store one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement any one of the session maintaining methods provided by the embodiments of the present application.
[0020] In a fourth aspect, a storage medium including computer executable instructions is provided, and the computer executable instructions, when executed by a computer processor, are used to perform any one of the session maintaining methods provided by the embodiments of the present application.
[0021] The application extracts the target module identifier from the access request after ending the access to the current module in response to the access request for the target module, determines the corresponding module according to the target module identifier; acquires the target session identifier generated by the target module in the historical session process from the session relationship table of the local client by using the target module identifier, and can realize session maintenance by acquiring the target session identifier in the historical session process; sends a session verification request to the server corresponding to the target module according to the target module identifier and the target session identifier, and the server performs the following: determines whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determines the target session information associated with the target session identifier, and feeds back the target session information to the client, acquires the session information from the server by verifying the information, judges whether the target session generated in the historical session is valid by sending the verification information to the server, and acquires the session information in the case of validity; continues to access the target module based on the target session information, can continue to access the target module according to the session information of the target module after ending the access to the current module, and realizes session maintenance of multiple modules. The method of the application is executed by the client, the target session identifiers of various modules are stored in the local client, and do not need to be stored by a third party, overcoming the problems of reduced session security and untrusted third party due to leakage of third party key, and since the storage is in the client, there is no problem of storage space abuse, achieving the effects of improving the security of the session and realizing session maintenance. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of a session maintenance method in the first embodiment of the application;
[0023] Figure 2 is a flowchart of a session maintenance method in the second embodiment of the application;
[0024] Figure 3 is a structural schematic diagram of a session maintenance device in the third embodiment of the application;
[0025] Figure 4 is a structural schematic diagram of an electronic device in the fourth embodiment of the application. DETAILED DESCRIPTION
[0026] In order to enable personnel in the technical field to better understand the application scheme, the technical solutions in the embodiments of the application will be clearly and completely described below in conjunction with the drawings in the embodiments of the application. Obviously, the described embodiments are only a part of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor should belong to the protection scope of the application.
[0027] It should be noted that the terms "first", "second", and the like in the description and in the claims of the present application and the above-described accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular sequential or chronological order. It should be understood that the data thus used can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in other than the order illustrated or described herein. In addition, the terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that includes a list of steps or units is not necessarily limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to such processes, methods, products, or apparatus.
[0028] Embodiment One
[0029] Figure 1 A flowchart of a session maintaining method provided for Embodiment One of the present application, the embodiment can be applicable to the case of maintaining a session when switching between different modules in an application, the method can be executed by a session maintaining device, the device can be implemented by software and / or hardware, and is specifically configured in a client, for example, a mobile phone.
[0030] Referring to Figure 1 The session maintaining method is applied to a client, and specifically includes the following steps:
[0031] S110, after ending the access to the current module, in response to the access request to the target module, extracting the target module identifier from the access request.
[0032] The current module can be a module that is currently being accessed, and ending the access to the current module can be ending the session with the current module. The target module can be a module that needs to be accessed to implement a certain function. The target module can be a module that has been accessed before this access, or a module that has not been accessed, which is not limited by the present application. There can be multiple independent modules in an application program for implementing different functions. For example, there can be a business handling module, a business query module, and a business evaluation module, etc. in an application program. When using a module to complete a certain function, it can be necessary to switch to other modules in the middle and then switch back to the original module to continue handling. For example, when handling a business through the business handling module, some steps need to fill in information, which can need to query through the business query module and then return to the business handling module to continue handling.
[0033] The access request can be a request for accessing the target module to operate the target module. For example, the access request for the target module can be generated when it is monitored that a button or an icon of the target module in the application is clicked. The target module identifier can be a unique identifier of the target module, used to distinguish the target module. For example, the target module identifier can be assigned by the mobile gateway to the target module. Specifically, the mobile gateway provides a registration portal for the target module, and assigns the target module identifier to the target module after the target module is registered. After the access request for the target module is monitored, the target module identifier can be extracted from the access request.
[0034] S120, using the target module identifier, obtaining a target session identifier generated in a historical session process of the target module from a session relationship table of the local client.
[0035] The target session identifier can be a session identifier corresponding to the target module, used to maintain session information. For example, the target session identifier can be a session identifier generated in a historical session process. The session relationship table can be a table stored in the local client, used to store the correspondence between the target module, the target session identifier and the target module identifier, etc. After the target module identifier is extracted, the target session identifier generated in the historical session process is obtained from the session relationship table of the local client according to the target module identifier.
[0036] In an optional embodiment, the session relationship table is pulled from a server corresponding to the main module during the startup process of the local client. The session relationship table includes each candidate module identifier, candidate session identifier and session expiration time corresponding to the candidate session identifier. The initial value of the candidate session identifier and the initial value of the session expiration time corresponding to the candidate session identifier are both empty.
[0037] The main module can be a menu module in the application program, including the identifiers of all candidate modules, to ensure the comprehensiveness of the subsequent pulling of the session relationship table. The server corresponding to the main module can be a server accessed according to the routing relationship corresponding to the main module. The routing paths of different candidate modules in the client to access the server can be different.
[0038] The session expiration time can be a session identifier expiration time, used to determine the validity of the session identifier, i.e. if the session expiration time is exceeded, the corresponding session identifier is invalid. Specifically, the target session has a certain validity time, for example, 20 minutes, i.e. within 20 minutes after the target session is not operated, the target session identifier is valid. The validity time can be set according to the performance of the target module and the corresponding business, etc. when the target module is developed. According to the validity time of the target module and the time of the last operation time, the last operation time is delayed by the validity time to obtain the session expiration time.
[0039] The candidate modules can be modules in an application program, used to implement different functions. The candidate session identifiers can be session identifiers of the candidate modules. The candidate module identifiers can be module identifiers of the candidate modules. In the local client startup process, according to a routing path of the main module corresponding service end, a session relationship table is downloaded from the mobile routing, the session relationship table including the candidate module identifiers, the candidate session identifiers, and the session expiration moments corresponding to the candidate session identifiers, the candidate module identifiers, the candidate session identifiers, and the session expiration moments corresponding to the candidate session identifiers corresponding one by one. In the local client startup process, no session has occurred, and the initial values of the candidate session identifiers and the session expiration moments corresponding to the candidate session identifiers are both set as empty.
[0040] In the local client startup process, the session relationship table is pulled from the main module corresponding service end through the session relationship table, the session relationship table including the candidate module identifiers, the candidate session identifiers, and the session expiration moments corresponding to the candidate session identifiers; the initial value of the candidate session identifier and the initial value of the session expiration moment corresponding to the candidate session identifier are both empty; the session relationship table is generated in the local client, and when a session request is sent to the service end subsequently, the session identifier can be obtained from the local client to realize session maintenance, without relying on a third party to store the session identifier, and the security and convenience of session maintenance are improved.
[0041] In an optional embodiment, the target module identifier is used to obtain a target session identifier generated by the target module in a historical session process from the session relationship table of the local client, including: if the target session identifier corresponding to the target module is empty, requesting the target module corresponding service end to newly build a session for the target module, and obtaining a new session identifier and a corresponding session expiration moment; and using the new session identifier and the corresponding session expiration moment to update the target session identifier and the session expiration moment corresponding to the target module.
[0042] The new session identifier can be a globally unique session identifier newly generated by the target module corresponding service end for the target module when the session identifier of the target module identifier is empty, used to identify the session information of the newly built session of the target module. The target module corresponding service end can be a service end determined according to the routing relationship of the target module. The service ends corresponding to different modules can be deployed in different positions, and the session information of each module is more secure. The original empty value is updated with the new session identifier. When the session identifier is obtained, the new session identifier and the corresponding session expiration moment are obtained from the target module corresponding service end at the same time, and the session expiration moment corresponding to the target module is updated.
[0043] If the target session identifier corresponding to the target module is empty, the target module corresponding server is requested to newly create a session for the target module, and a new session identifier and a corresponding session expiration time are obtained; the target session identifier and the session expiration time corresponding to the target module are updated by using the new session identifier and the corresponding session expiration time, a new session is created and the target session identifier and the session expiration time corresponding to the target module are updated when the session is not established, and the session identifier and the session expiration time of the new session information of the target module are obtained in time, so as to facilitate subsequent session maintenance.
[0044] S130, according to the target module identifier and the target session identifier, a session verification request is sent to the target module corresponding server, and the server performs the following: according to the target module identifier and the target session identifier, it is determined whether the target session identifier is valid; in the case of validity, the target session information associated with the target session identifier is determined, and the target session information is fed back to the client.
[0045] The session verification request can be information for verifying the session information sent to the server, which is used to determine whether the target module identifier and the target session identifier corresponding relationship is correct, and whether the target session identifier is valid. Specifically, the target module identifier and the target session identifier are added to the request header of the verification request to generate a session verification request, which is sent to the target module corresponding server.
[0046] After the target module corresponding server receives the session verification request, it is determined whether the target session identifier is valid according to the target module identifier and the target session identifier. For example, it is detected whether the target module identifier and the target session identifier corresponding relationship is correct, and the historical record information of the target session is obtained according to the target session identifier, the historical end time of the target session is determined, the session expiration time is determined according to the pre-set target session information maintenance time, and then it is determined whether the target session identifier is valid.
[0047] In the case of validity, the target session information associated with the target session identifier is determined, and the target session information is fed back to the client.
[0048] S140, based on the target session information, continue to access the target module.
[0049] The target session information can be information associated with the target session identifier, which is used to continue to access the target module. For example, the target session information can be information that has been operated, and the historical access page is restored based on the session information to continue to operate.
[0050] In an optional embodiment, the session maintaining method further comprises: obtaining the session expiration time of the target session identifier from the local session relationship table according to the target session identifier; determining whether the target session identifier is valid according to the session expiration time; if it is determined that the target session identifier is invalid, sending a session new creation request to the server corresponding to the target module, and generating a new session identifier and a session expiration time for the target module by the server corresponding to the target module and feeding back to the client; and updating the target session identifier and the corresponding session expiration time in the local session relationship table by using the new session identifier and the session expiration time obtained from the server.
[0051] The session expiration time of the target session identifier is obtained from the local session relationship table according to the target session identifier. The session expiration time can be the final time when the session information can be valid, which is used to determine whether the target session identifier is valid at the current time. If the time when the session verification request is sent to the server exceeds the session expiration time, it is determined that the target session identifier is locally invalid. When the target session identifier is locally invalid, a session new creation request is sent to the server corresponding to the target module, a new target session is created for the target module by the server corresponding to the target module, a new session identifier and a session expiration time are generated and fed back to the client. The client updates the target session identifier and the corresponding session expiration time in the local session relationship table by using the new session identifier and the session expiration time obtained from the server, so as to send a session verification request to the server according to the updated target session identifier, and update the corresponding session expiration time in time.
[0052] By obtaining the session expiration time of the target session identifier from the local session relationship table according to the target session identifier, determining whether the target session identifier is valid according to the session expiration time, if it is determined that the target session identifier is invalid, sending a session new creation request to the server corresponding to the target module, generating a new session identifier and a session expiration time for the target module by the server corresponding to the target module and feeding back to the client, and updating the target session identifier and the corresponding session expiration time in the local session relationship table by using the new session identifier and the session expiration time obtained from the server, the validity of the session identifier can be determined locally at the client, unnecessary traffic is avoided by sending a session verification request to the server by using the target session identifier exceeding the session expiration time, and the server resource is wasted after the client is reminded by the server that the session identifier is invalid.
[0053] In an optional embodiment, after determining whether the target session identifier is valid according to the session expiration time, the method further comprises: if it is determined that the target session identifier is valid, updating the session expiration time of the target session identifier after continuing to access the target module.
[0054] If it is determined that the target session identifier is valid, that is, the moment when the session verification request is sent to the server does not exceed the session expiration moment, the target session identifier is valid at this time. After continuing to access the target module, a new operation is performed on the session, and therefore the session expiration moment of the target session identifier is updated according to the latest operation moment, so as to ensure the correctness of the session expiration moment. Specifically, the session expiration moment is updated by adding the current moment of each operation on the target session and the valid time.
[0055] By determining that the target session identifier is valid, the session expiration moment of the target session identifier is updated after continuing to access the target module, so as to ensure that the session expiration moment is updated in real time according to the actual operation time of the target session, and the correctness and real-time performance of the session expiration time are ensured.
[0056] In the prior art, a distributed session sharing scheme is used, that is, a session storage warehouse separated from an application is used, and session information of each module is stored in the warehouse. When a user accesses a session, each independent module can use a globally unique session identifier to obtain session information of the user from the warehouse. Because all modules use the same session warehouse to store session information, the modules are coupled together and are not truly independent. The following problems may occur: there is a single point problem, once the session warehouse has a problem, all modules of the application program based on the session cannot be used; the session warehouse is shared, the storage space is limited, and the problem of misuse of the session space by the modules is difficult to manage; if a module is an independent module provided by a third party and the operation is not fully trusted, the session sharing permission will not be provided, and the session maintenance function cannot be used when the module is switched; all sessions exist in the same place, and once the warehouse key of a module is leaked, the security of all modules will be affected.
[0057] The technical scheme of the embodiment, after ending the access to the current module, in response to the access request of the target module, extracts the target module identifier from the access request, and determines the corresponding module according to the target module identifier; the target module identifier is used to obtain the target session identifier generated by the target module in the historical session process from the session relationship table of the local client, and the session maintenance can be realized by obtaining the target session identifier in the historical session process; according to the target module identifier and the target session identifier, a session verification request is sent to the server corresponding to the target module, and the server executes the following: according to the target module identifier and the target session identifier, it is determined whether the target session identifier is valid; in the case of validity, the target session information associated with the target session identifier is determined, and the target session information is fed back to the client; the session information is obtained from the server through the verification information, the target session generated in the historical session is judged to be valid by sending the verification information to the server, and the session information is obtained in the case of validity; based on the target session information, the target module is continuously accessed, the target module can be continuously accessed according to the session information of the target module after ending the access to the current module, and the session maintenance of multiple modules is realized. The method of the application is executed by the client, the target session identifier of each module is stored in the local client, and there is no need for third-party storage, which overcomes the problems of reduced session security due to third-party key leakage and untrusted third party, and since it is stored in the client, there is no problem of storage space abuse, and the effects of improving the security of the session and realizing the session maintenance are achieved.
[0058] Embodiment two
[0059] Figure 2 The flowchart of the session maintenance method provided by the second embodiment of the application is a flowchart of the method. The technical scheme of the embodiment is further refined on the basis of the above technical scheme.
[0060] Further, after the target module identifier is used to obtain the target session identifier generated by the target module in the historical session process from the session relationship table of the local client, the following is added: "the target module identifier is used to obtain the target authentication token of the target module from the session relationship table of the local client; the target authentication token is the encrypted module authentication code of the target module", so as to obtain the target token;
[0061] Correspondingly, the step of sending a session verification request to the server corresponding to the target module according to the target module identifier and the target session identifier comprises the following steps of: according to the target authentication token, performing the following steps by the server corresponding to the target module: decrypting the target authentication token to obtain a module authentication code of the target module, and verifying the legality of the module authentication code; in the case that the module authentication code is legal, determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case that the target session identifier is valid, determining target session information associated with the target session identifier, and feeding back the target session information to the client.
[0062] Referring to Figure 2 The session maintaining method shown in the figure comprises the following steps of:
[0063] S210, in response to an access request for a target module, extracting a target module identifier from the access request.
[0064] S220, using the target module identifier, obtaining a target session identifier generated by the target module in a historical session process from a session relationship table of the local client.
[0065] S230, using the target module identifier, obtaining a target authentication token of the target module from the session relationship table of the local client; the target authentication token is a module authentication code of the target module after encryption.
[0066] The target authentication token can be an authentication token of the target module, used for authenticating the identifier of the target module, serving as authentication information of the target module, so as to guarantee the security of the session information of the target module. If the target authentication token is incorrect, even if the target module and the target session identifier are intercepted, the target session information cannot be obtained. The target authentication token is a module authentication code of the target module after encryption, and the encryption mode can be symmetric encryption or asymmetric encryption. The application does not make a specific limitation on this, and the encryption mode and the encryption key can be changed periodically. According to the target module identifier, the target authentication token of the target module is obtained from the session relationship table of the local client.
[0067] S240, according to the target authentication token, performing the following steps by the server corresponding to the target module: decrypting the target authentication token to obtain a module authentication code of the target module, and verifying the legality of the module authentication code; in the case that the module authentication code is legal, determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case that the target session identifier is valid, determining target session information associated with the target session identifier, and feeding back the target session information to the client.
[0068] The target authentication token, the target module identifier and the target session identifier are added to the request header of the verification request, a session verification request is generated, and the session verification request is sent to the server corresponding to the target module.
[0069] The server corresponding to the target module receives the session verification request, decrypts the target authentication token according to the encryption mode to obtain the module authentication code of the target module, and verifies the legality of the module authentication code. After verifying the legality of the module authentication code, whether the target session identifier is valid is determined according to the target module identifier and the target session identifier. Specifically, whether the correspondence between the target module identifier and the target session identifier is correct is detected, the historical record information of the target session is obtained according to the target session identifier, the historical end time of the target session is determined, the session expiration time of the target session is determined according to the pre-set holding time of the target session information, whether the target session identifier is valid is determined according to the sending time of the request and the session expiration time of the target session. In the case of validity, the target session information associated with the target session identifier is determined, and the target session information is fed back to the client.
[0070] S250, based on the target session information, continue to access the target module.
[0071] The technical scheme of the embodiment, by adopting the target module identifier, the target authentication token of the target module is obtained from the session relationship table of the local client; the target authentication token is the encrypted module authentication code of the target module; a target authentication token is added for each module to ensure the independence and security between modules. According to the target authentication token, the server corresponding to the target module performs the following: decrypting the target authentication token to obtain the module authentication code of the target module, and verifying the legality of the module authentication code; in the case of legal module authentication code, whether the target session identifier is valid is determined according to the target module identifier and the target session identifier; in the case of validity, the target session information associated with the target session identifier is determined, and the target session information is fed back to the client; the server corresponding to the target module determines the target session information associated with the target session identifier in the case of valid target authentication token, and feeds back the target session information to the client, increases the correctness of verifying the target token, and further improves the security of the session information.
[0072] Embodiment three
[0073] Figure 3 The structure of the session keeping device provided by the embodiment three is shown, the embodiment can be applied to the case of keeping the session when switching between different modules in application, and is configured in the client. The specific structure of the session keeping device is as follows:
[0074] The target module identifier extraction module 310 is configured to extract the target module identifier from the access request in response to the access request for the target module after ending the access to the current module;
[0075] The target session identifier obtaining module 320 is configured to obtain, from the session relationship table of the local client, a target session identifier generated by the target module in a historical session process, by using the target module identifier.
[0076] The session verification request sending module 330 is configured to send, to the server corresponding to the target module, a session verification request according to the target module identifier and the target session identifier, and the server is configured to perform the following operations: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determining target session information associated with the target session identifier, and feeding back the target session information to the client.
[0077] The target module accessing module 340 is configured to continue to access the target module based on the target session information.
[0078] The technical scheme of the embodiment, after ending the access to the current module, in response to the access request for the target module, the target module identifier is extracted from the access request, and the corresponding module is determined according to the target module identifier; the target session identifier generated by the target module in the historical session process is obtained from the session relationship table of the local client by using the target module identifier, the target session identifier in the historical session process is obtained, and the session maintenance can be realized; according to the target module identifier and the target session identifier, the session verification request is sent to the server corresponding to the target module, and the server is configured to perform the following operations: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determining target session information associated with the target session identifier, and feeding back the target session information to the client. The session information is obtained from the server by verifying the information, it is judged whether the target session generated in the historical session is valid by sending the verification information to the server, and the session information is obtained in the case of validity; based on the target session information, the target module is continued to be accessed, the target module can be continued to be accessed according to the session information of the target module after ending the access to the current module, and the session maintenance of multiple modules is realized. The method of the application is executed by the client, the target session identifiers of various modules are stored in the local client, and there is no need for a third party to store, which overcomes the problems of reduced session security due to third-party key leakage and untrusted third party, and since the storage is in the client, there is no problem of storage space abuse, and the effects of improving the security of the session and realizing the session maintenance are achieved.
[0079] Optionally, the session relationship table is pulled from the server corresponding to the main module during the starting process of the local client, and the session relationship table includes various candidate module identifiers, candidate session identifiers, and session expiration moments corresponding to the candidate session identifiers; the initial value of the candidate session identifier and the initial value of the session expiration moment corresponding to the candidate session identifier are empty.
[0080] Optionally, the target session identifier obtaining module 320 further comprises:
[0081] The session identifier establishing unit is configured to, if the target session identifier corresponding to the target module is empty, request a server corresponding to the target module to newly create a session for the target module, and acquire a new session identifier and a corresponding session expiration time;
[0082] The session identifier updating unit is configured to update the target session identifier and the session expiration time corresponding to the target module by using the new session identifier and the corresponding session expiration time.
[0083] Optionally, the session maintaining apparatus further comprises:
[0084] The local expiration time acquiring module is configured to acquire the session expiration time of the target session identifier from a local session relationship table according to the target session identifier;
[0085] The validity determining module is configured to determine whether the target session identifier is valid according to the session expiration time;
[0086] The session newly creating requesting module is configured to, if it is determined that the target session identifier is invalid, send a session newly creating request to the server corresponding to the target module, and generate a new session identifier and a session expiration time for the target module by the server corresponding to the target module and feed back to the client;
[0087] The local session relationship table updating module is configured to update the target session identifier and the corresponding session expiration time in the local session relationship table by using the new session identifier and the session expiration time acquired from the server.
[0088] Optionally, the session maintaining apparatus further comprises:
[0089] The expiration time updating module is configured to, if it is determined that the target session identifier is valid, update the session expiration time of the target session identifier after continuously accessing the target module.
[0090] Optionally, the session maintaining apparatus further comprises:
[0091] The target authentication token acquiring module is configured to acquire a target authentication token of the target module from a session relationship table of the local client by using the target module identifier; the target authentication token is a module authentication code of the target module after encryption;
[0092] Correspondingly, the session verifying requesting module is configured to: according to the target authentication token, execute the following by the server corresponding to the target module: decrypt the target authentication token to obtain a module authentication code of the target module, and verify the legality of the module authentication code; in the case that the module authentication code is legal, determine whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case that it is valid, determine target session information associated with the target session identifier, and feed back the target session information to the client.
[0093] The session persistence device provided in this application embodiment can execute the session persistence method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the session persistence method.
[0094] Example 4
[0095] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of this application, as shown below. Figure 4 As shown, the electronic device includes a processor 410, a memory 420, an input device 430, and an output device 440; the number of processors 410 in the electronic device can be one or more. Figure 4 Taking a processor 410 as an example; the processor 410, memory 420, input device 430, and output device 440 in the electronic device can be connected via a bus or other means. Figure 4 Taking the example of a connection between China and Israel via a bus.
[0096] The memory 420, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the session persistence method in the embodiments of this application (e.g., target module identifier extraction module 310, target session identifier acquisition module 320, session verification request sending module 330, and target module access module 340). The processor 410 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 420, thereby implementing the aforementioned session persistence method.
[0097] The memory 420 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 420 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 420 may further include memory remotely located relative to the processor 410, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0098] Input device 430 can be used to receive input character information and generate key signal inputs related to user settings and function control of the electronic device. Output device 440 may include display devices such as a display screen.
[0099] Example 5
[0100] The embodiment five of the present application further provides a storage medium comprising computer executable instructions, which are used for executing a session maintaining method when executed by a computer processor, and the method comprises the following steps: after ending the access to a current module, in response to an access request for a target module, extracting a target module identifier from the access request; using the target module identifier to obtain a target session identifier generated by the target module in a historical session process from a session relationship table of a local client; according to the target module identifier and the target session identifier, sending a session verification request to a server corresponding to the target module, and the server executes the following: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determining target session information associated with the target session identifier, and feeding back the target session information to the client; and based on the target session information, continuing to access the target module.
[0101] Of course, the storage medium comprising computer executable instructions provided by the embodiment of the present application is not limited to the method operations as described above, and can also execute the related operations in the session maintaining method provided by any embodiment of the present application.
[0102] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be realized by means of software and necessary general hardware, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a floppy disk, a read-only memory (ROM), a random access memory (RAM), a FLASH memory, a hard disk or an optical disk, and includes a number of instructions to make an electronic device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in various embodiments of the present application.
[0103] It is worth noting that in the above embodiment of the search device, each unit and module included is only divided according to functional logic, but is not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy mutual distinction, and do not limit the protection scope of the present application.
[0104] It is to be noted that the above-mentioned embodiments illustrate rather than limit the application, and that those skilled in the art will be able to design many alternative embodiments without departing from the scope of the application. The word "comprising" does not exclude the presence of elements or steps other than those listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. It is further noted that characteristics relating to the different embodiments can be combined, and not just those within respective sections of the description.
Claims
1. A session maintenance method characterized by, The method applied to a client comprises: after ending the access to the current module, in response to an access request to a target module, extracting a target module identifier from the access request; the current module and the target module are different modules in an application program and are used to implement different functions; using the target module identifier, obtaining a target session identifier generated by the target module in a historical session process from a session relationship table of the local client; according to the target module identifier and the target session identifier, sending a session verification request to a server corresponding to the target module, and performing the following by the server: determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case that the session identifier is valid, determining target session information associated with the target session identifier, and feeding back the target session information to the client; based on the target session information, continuing to access the target module; the target session information is information associated with the target session identifier and is used to continue to access the target module; after the step of using the target module identifier to obtain the target session identifier generated by the target module in the historical session process from the session relationship table of the local client, the method further comprises: using the target module identifier, obtaining a target authentication token of the target module from the session relationship table of the local client; the target authentication token is a module authentication code of the target module after encryption; correspondingly, the step of sending a session verification request to a server according to the target module identifier comprises: according to the target authentication token, performing the following by the server corresponding to the target module: decrypting the target authentication token to obtain a module authentication code of the target module, and verifying the legality of the module authentication code; in the case that the module authentication code is legal, determining whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case that the target session identifier is valid, determining target session information associated with the target session identifier, and feeding back the target session information to the client.
2. The method of claim 1, wherein, in the process of starting the local client, a session relationship table is pulled from a server corresponding to a main module; the session relationship table comprises candidate module identifiers, candidate session identifiers, and session expiration time points corresponding to the candidate session identifiers; the initial value of the candidate session identifier and the initial value of the session expiration time point corresponding to the candidate session identifier are both empty.
3. The method of claim 2, wherein, the step of using the target module identifier to obtain the target session identifier generated by the target module in the historical session process from the session relationship table of the local client comprises: if the target session identifier corresponding to the target module is empty, requesting the server corresponding to the target module to newly create a session for the target module, and obtaining a new session identifier and a corresponding session expiration time point; using the new session identifier and the corresponding session expiration time point, updating the target session identifier and the session expiration time point corresponding to the target module.
4. The method according to any one of claims 1-3, characterized in that, the method further comprises: according to the target session identifier, obtaining a session expiration time point of the target session identifier from the local session relationship table; determine whether the target session identifier is valid according to the session expiration time; if it is determined that the target session identifier is invalid, send a session creation request to a server corresponding to the target module, and generate a new session identifier and a session expiration time for the target module by the server corresponding to the target module and feed back to the client; update the target session identifier and the corresponding session expiration time in the local session relationship table by using the new session identifier and the session expiration time obtained from the server.
5. The method of claim 4, wherein, After determining whether the target session identifier is valid according to the session expiration time, the method further comprises: if it is determined that the target session identifier is valid, update the session expiration time of the target session identifier after continuing to access the target module.
6. A session maintenance apparatus characterized by comprising: The client comprises: a target module identifier extraction module, configured to extract a target module identifier from an access request for a target module after ending access to a current module; the current module and the target module are different modules in an application program and are used to implement different functions; a target session identifier acquisition module, configured to acquire a target session identifier generated by the target module in a historical session process from a session relationship table of a local client by using the target module identifier after ending access to the current module; a session verification request sending module, configured to send a session verification request to a server corresponding to the target module according to the target module identifier and the target session identifier, and configured to cause the server to perform the following: determine whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determine target session information associated with the target session identifier, and feed back the target session information to the client; a target module access module, configured to continue to access the target module based on the target session information; the target session information is information associated with the target session identifier and is used to continue to access the target module. The session maintaining device further comprises: a target authentication token acquisition module, configured to acquire a target authentication token of the target module from the session relationship table of the local client by using the target module identifier; the target authentication token is a module authentication code of the target module after encryption; correspondingly, the session verification request sending module is configured to: according to the target authentication token, cause the server corresponding to the target module to perform the following: decrypt the target authentication token to obtain a module authentication code of the target module, and verify the legality of the module authentication code; in the case of legality of the module authentication code, determine whether the target session identifier is valid according to the target module identifier and the target session identifier; in the case of validity, determine target session information associated with the target session identifier, and feed back the target session information to the client.
7. The apparatus of claim 6, wherein, The device further comprises: an expiration time acquisition module, configured to acquire a session expiration time of the target session identifier from the local session relationship table according to the target session identifier; an effectiveness determination module, configured to determine whether the target session identifier is valid according to the session expiration time. The new target session identification request module is configured to, if it is determined that the target session identification is invalid, send a session new creation request to a server corresponding to the target module, and generate a new session identification and a session expiration time for the target module by the server corresponding to the target module and feed back to the client; The target session identification updating module is configured to update the target session identification and the corresponding session expiration time in the local session relationship table by using the new session identification and the session expiration time obtained from the server.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the session maintenance method of any one of claims 1-5 when executing the program.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the session maintenance method of any one of claims 1-5.
Citation Information
Patent Citations
Session establishment method and apparatus, and client device and computer storage medium
WO2023045313A1