A method for automatic session updates
By periodically querying the remaining session time on the POS terminal and combining it with a credibility score, the session status is automatically updated, which solves the interruption and security risks caused by POS terminal session expiration and improves security and smoothness.
Patent Information
- Application Number
- CN202611288133.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-17
AI Technical Summary
In traditional POS terminal session management, sessions need to be manually renewed after they expire, which makes the process cumbersome and prone to interruption due to operational negligence. Furthermore, in abnormal situations, unauthorized terminals can obtain legitimate session credentials, leading to security incidents.
During the operation of the POS terminal, the remaining session time is queried at preset intervals and a dynamic update threshold is obtained. Combined with the credibility score of identity data, a new session request is sent to the server only when the credibility reaches the threshold, and identity verification and session creation are performed to update the local status.
This avoids session timeout interruptions, improves the security and smoothness of payment transactions, prevents abnormal terminals from obtaining new session credentials, and ensures that sessions are legitimate and valid.
Smart Images

Figure CN123122909A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of mobile payment security technology, and in particular to a method, apparatus and storage medium for automatic session update. Background Technology
[0002] With the widespread use of POS terminals in payment transaction scenarios, session management has become a crucial aspect of ensuring transaction continuity and security for POS machines. However, traditional session mechanisms often employ fixed-duration strategies, requiring manual renewal by operators after session expiration. This process is not only cumbersome and inefficient but also prone to interruption due to operator negligence.
[0003] To address the issue of transaction interruption caused by session expiration in POS terminals, existing technologies provide a session refresh method based on a fixed time period. This method sends session update requests to the server at preset intervals before the session expires to maintain the validity of the session and thus ensure the continuity of the payment process.
[0004] However, when the POS terminal is in an abnormal state, the session refresh method will still perform session update operations at preset intervals, causing the terminal in the abnormal state to illegally obtain legitimate new session credentials, enabling various terminal intrusions and identity forgery attacks to continue covertly, thereby causing security incidents such as transaction data leakage and merchant fund theft. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a method, apparatus, and storage medium for automatic session updates.
[0006] The technical solution provided in this application is described below: A first aspect of this application provides a method for automatic session update, the method comprising: During the operation of the POS terminal, the remaining time of the current session is queried according to the preset time period, and the dynamic session update threshold is obtained; Determine whether the remaining time is less than the dynamic session update threshold; If so, the credibility score of the identity data of the POS terminal is calculated based on the current transaction status, and it is determined whether the credibility score is lower than a preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. If the credibility score is not lower than the preset security threshold, then a new login session request is sent to the server based on the login credentials of the POS terminal, so that after receiving the new login session request, the server performs identity verification and session creation based on the new login session request and obtains the execution result; Receive the execution result and update the local session state based on the execution result.
[0007] Optionally, the step of scoring the credibility of the identity data of the POS terminal based on the current transaction status includes: Determine whether the POS terminal is currently conducting a payment transaction; If not, the current hardware characteristics of the POS terminal are compared with the initial hardware characteristics to obtain the device matching degree; The credibility of the public network address is obtained by detecting whether the public network address of the POS terminal is in the preset trusted network address whitelist. The current operating mode of the POS terminal is compared with the historical operating mode to obtain the behavior deviation degree; The device matching degree, the public network address credibility, and the behavior deviation degree are weighted and fused according to preset weights to obtain a credibility score.
[0008] Optionally, after determining whether the POS terminal is conducting a payment transaction, the method further includes: If so, the transaction status will be continuously monitored until the transaction is completed, and then the credibility score of the identity data of the POS terminal will be calculated.
[0009] Optionally, updating the local session state based on the execution result includes: Determine whether the execution result indicates a successful login to a new session; If so, update the local session state based on the execution result; If not, determine whether the number of times the new login session request has been sent to the server is less than a preset threshold. If so, then resend the new login session request to the server based on the login credentials; If not, pause new session updates, notify the user to manually log in to obtain a manual login session, and update the local session state based on the manual login session.
[0010] Optionally, obtaining the dynamic session update threshold includes: During the POS terminal startup process, obtain the total session duration, session query response time, transaction status, and business time period; The first session update threshold is calculated based on the preset relative session threshold and the total session duration; The minimum value between the first session update threshold and the preset absolute session threshold is set as the second session update threshold; The network quality of the current session is calculated based on the session query response time to obtain the first adjustment factor; The transaction status is matched with a preset transaction status threshold, and a second adjustment factor is determined based on the matching result; The business period is matched with a preset period threshold, and a third adjustment factor is determined based on the matching result; The second session update threshold is corrected based on the first adjustment factor, the second adjustment factor, and the third adjustment factor to obtain the dynamic session update threshold.
[0011] Optionally, after determining whether the remaining time is less than the dynamic session update threshold, the method further includes: If not, continue to query the remaining time of the current session according to the preset time period until the remaining time of the current session is less than the dynamic session update threshold.
[0012] Optionally, after determining whether the credibility score is lower than a preset security threshold, the method further includes: If the credibility score is lower than the preset security threshold, the new session update is paused, and the user is notified to log in manually to obtain a manual login session. The local session status is then updated based on the manual login session.
[0013] A second aspect of this application provides a session auto-update apparatus, the apparatus comprising: The query unit is used to query the remaining time of the current session according to a preset time period during the operation of the POS terminal, and to obtain the dynamic session update threshold. The first judgment unit is used to determine whether the remaining time is less than the dynamic session update threshold; The second judgment unit is used to perform a credibility score on the identity data of the POS terminal based on the current transaction status when the first judgment unit determines that the remaining session time is less than the dynamic session update threshold, and to determine whether the credibility score is lower than a preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. The sending unit is configured to send a new login session request to the server based on the login credentials of the POS terminal when the second judgment unit determines that the credibility score is not lower than the preset security threshold, so that the server, after receiving the new login session request, performs identity verification and session creation based on the new login session request and obtains the execution result; An execution unit is used to receive the execution result and update the local session state based on the execution result.
[0014] A third aspect of this application provides a session automatic update apparatus, the apparatus comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the first aspect and any one of the optional methods in the first aspect.
[0015] A fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods of the first aspect and any one of the first aspects.
[0016] As can be seen from the above technical solutions, this application has the following beneficial effects: This application proactively queries the remaining session time and synchronously obtains a dynamic session update threshold at preset intervals during POS terminal operation. This allows for early detection of impending session expiration, preventing transaction interruptions due to session timeout. The remaining time is then compared with the dynamic session update threshold, enabling flexible adjustment of the triggering timing based on actual operating scenarios. This avoids premature or delayed renewal checks, adapting to different transaction statuses. Next, when the remaining session time is less than the dynamic session update threshold, a credibility score is performed on the POS terminal's identity data. This security assessment, preceding the session update operation, effectively prevents unauthorized terminals from obtaining new session credentials. Finally, when the credibility score reaches a preset security threshold, a new session login request is sent to the server. The server then performs identity verification and session creation based on the request, updates its local session state upon receiving the server's response, ensuring the new session's legitimacy and validity, further enhancing payment transaction security. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic flowchart of an embodiment of the session automatic update method of this application; Figure 2 A schematic diagram of an embodiment of the automatic session update method of this application for performing credibility scoring; Figure 3 A schematic flowchart illustrating an embodiment of the automatic session update method of this application for updating the local session state; Figure 4 A schematic flowchart of an embodiment of the automatic session update method of this application for obtaining the dynamic session update threshold; Figure 5 This is a schematic flowchart of one embodiment of the session automatic update device of this application; Figure 6 This is a schematic diagram of another embodiment of the session automatic update device of this application. Detailed Implementation
[0019] It should be noted that the execution entity of the automatic session update method provided in this embodiment is not limited to a specific hardware device or software module. This method can be executed independently by the POS terminal device, by a backend server or cloud platform communicating with the POS terminal, or by the POS terminal and server working together. For example, in some implementations, steps such as querying the remaining session time, calculating the dynamic threshold, and performing credibility scoring are all completed locally by the POS terminal, with the server only responsible for responding to renewal requests and returning execution results. In other implementations, the calculation of the dynamic threshold and the fusion of the credibility score can be completed by the server, with the POS terminal only responsible for collecting identity data and initiating requests. Those skilled in the art will understand that, depending on the actual application scenario and system architecture, the execution entity of the above method steps can be flexibly configured, as long as the automatic session update function described in this application can be achieved; no specific restrictions should be placed on the execution entity here.
[0020] Please see Figure 1 This application first provides an embodiment of a session auto-update method, which includes: S101. During the operation of the POS terminal, query the remaining time of the current session according to the preset time period and obtain the dynamic session update threshold. In this embodiment, during the operation of the POS terminal, the system will trigger session status checks cyclically according to a preset time period. Each time the system triggers a session status check cyclically, it will simultaneously perform two tasks: querying the remaining time of the current session and obtaining the session update trigger threshold.
[0021] Specifically, when querying the remaining time of the current session, a heartbeat timer first triggers a heartbeat check every 30 seconds. Then, after the heartbeat timer is triggered, a heartbeat request message is sent to the local session state recording module. This message carries the token identifier of the current session to verify session legitimacy. The local session state recording module pre-caches the server-side absolute expiration time of the current session; this expiration time is synchronized from the server and stored upon successful login or renewal. Upon receiving the heartbeat request message and verifying the token's validity, the local session state recording module generates a heartbeat response message and writes the X-Session-Expires field to the response message header. The value of this field is the cached absolute expiration time of the current session. Upon receiving the heartbeat response message, the value of the X-Session-Expires field is parsed from the heartbeat response message header. Simultaneously, the current system clock timestamp is read. Subtracting the current system clock timestamp from the parsed absolute expiration time yields the remaining time of the current session.
[0022] Specifically, when obtaining the dynamic session update threshold, four basic parameters are collected sequentially: total session duration, session query response time, transaction status, and business period. Then, a first session update threshold is calculated by combining a preset relative threshold with the total session duration. Next, the first session update threshold is compared with a preset absolute threshold, and the minimum value is set as the second session update threshold to determine the threshold benchmark. Then, a first adjustment factor is obtained based on the session query response time, a second adjustment factor is obtained based on the transaction status, and a third adjustment factor is obtained based on the business period. Finally, the first, second, and third adjustment factors are multiplied together to obtain a comprehensive correction coefficient, which is then multiplied by the second session update threshold to obtain the dynamic session update threshold.
[0023] S102. Determine whether the remaining time is less than the dynamic session update threshold; In this embodiment, after obtaining the remaining time of the session and the dynamic session update threshold, the remaining time of the current session is compared with the dynamic session update threshold. If the remaining time of the current session is greater than or equal to the dynamic session update threshold, it indicates that the session is still within its safe validity period, and step S103 is executed; if the remaining time of the current session is less than the dynamic session update threshold, it indicates that the session is about to expire, and step S104 is executed.
[0024] S103. Continue to query the remaining time of the current session according to the preset time period until the remaining time of the current session is less than the dynamic session update threshold. In this embodiment, when the remaining time of the current session is determined to be not less than the dynamic session update threshold, it indicates that the current session is still within its safe validity period and there is no need to immediately trigger the renewal process. At this time, it is only necessary to continue to maintain the current session monitoring rhythm and wait for the next preset time period to arrive. When the next preset time period is triggered, a heartbeat request message is sent again to the local session status recording module. The X-Session-Expires field is parsed from the header of the heartbeat response message, and the updated remaining time of the current session is calculated by combining it with the timestamp of the current system clock. At the same time, the updated dynamic session update threshold is synchronously obtained from the heartbeat response message. Then, the updated remaining time of the current session is compared with the updated dynamic session update threshold again. If the remaining time of the current session is still not less than the dynamic session update threshold, the process continues to wait for the next preset time period and repeat the query and comparison process until the remaining time of the current session is less than the dynamic session update threshold in a certain comparison. At this time, the loop stops, and the identity data credibility scoring process of the POS terminal is entered.
[0025] S104. Calculate the credibility score of the identity data of the POS terminal based on the current transaction status, and determine whether the credibility score is lower than the preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. In this embodiment, when the remaining time of the current session is determined to be less than the dynamic session update threshold, the system first checks whether there is an ongoing payment transaction on the POS terminal. If there is an ongoing payment transaction, the transaction status is continuously monitored, and the identity data credibility scoring process is initiated only after the transaction is completed. If there is no payment transaction, the identity data of the POS terminal is directly scored for credibility. This identity data includes information in three dimensions: hardware characteristics, public network address, and operating mode. During scoring, the current hardware characteristics are first collected and compared with the initial hardware characteristics to obtain the device matching degree. Then, the current network egress public network address is checked to obtain the public network address credibility. Subsequently, the current operating mode is compared with the historical operating mode to obtain the behavior deviation degree. Next, the device matching degree, public network address credibility, and behavior deviation degree are weighted and fused to generate a credibility score. Finally, the credibility score is compared with a preset security threshold. If the credibility score is not lower than the preset security threshold, step S105 is executed; if the credibility score is lower than the preset security threshold, step S107 is executed.
[0026] S105. Send a new login session request to the server based on the login credentials of the POS terminal, so that after receiving the new login session request, the server performs identity verification and session creation based on the new login session request and obtains the execution result; Execute step S106; In this embodiment, after determining that the trust score is not lower than a preset security threshold, the encrypted authentication information is first read from the storage area. It should be noted that this encrypted authentication information is stored during the user's first login and includes username, password, and token data, protected by the AES-256-GCM encryption algorithm. Next, the CPU serial number and MAC address are collected from the current hardware environment and combined to form a device hardware ID. A preset Salt string is then concatenated with the device hardware ID as a derivation factor, and the PBKDF2-SHA256 algorithm is iterated 100,000 times to generate a 32-byte AES-256 decryption key. Then, this decryption key is used to decrypt the encrypted authentication information using AES-256-GCM, restoring the original username, password, and other login credentials. Subsequently, the decrypted login credentials are encapsulated according to the message format of a new login session request, constructing a complete new login session request message, which is then sent to the server.
[0027] When the server receives a new session login request message, it first verifies the login credentials carried in the message. It checks whether the username and password in the login credentials match the authentication records stored on the server. If the verification passes, a new session is created and a corresponding new session token and new session validity period are generated. The new session token and new session validity period are then encapsulated as an execution result and returned to the POS terminal. If the verification fails, the server refuses to create a new session and returns an execution result containing the reason for the failure to the POS terminal.
[0028] S106. Receive the execution result and update the local session state based on the execution result; In this embodiment, after receiving the execution result returned by the server, the status flag in the execution result is first parsed to determine whether the new session login was successful. If the status flag indicates success, the new session token and the corresponding session validity period are extracted from the execution result, the old session token stored locally is replaced with the new session token, and the session expiration time is updated according to the new session validity period to complete the update of the local session status. If the status flag indicates failure, the locally maintained request sending counter is further read to check whether the number of times a new session login request has been sent is less than three. If the number is less than three, after a preset interval, the login credentials in the secure storage area are read again, a new session login request is constructed and sent again, and the count value of the request sending counter is incremented by one. If the number has reached three, the automatic renewal process is paused, and a notification message containing the reason for failure is generated and sent to the user terminal, prompting the user to log in manually. After the user terminal manually completes the login and obtains a new session, the new session token and validity period are written locally to complete the update of the local session status.
[0029] S107. Pause the new session update, notify the client to manually log in to the new session to obtain a manual login session, and update the local session status according to the manual login session.
[0030] In this embodiment, after determining that the credibility score is lower than a preset security threshold, it indicates that the identity data of the current POS terminal is abnormal. This may be due to a mismatch between the device hardware characteristics and the initial registration fingerprint, the current public IP address not being on the trusted network address whitelist, or a significant deviation between the current operating mode and the historical operating mode, posing a security risk of session hijacking or illegal renewal. Therefore, it is not suitable to continue automatic renewal. At this time, the new session update process is immediately paused, and a security alarm notification message is generated and sent to the user terminal via preset communication channels such as SMS or email. After the user terminal manually logs in and obtains a new session, the new session token and its validity period are written locally to complete the update of the local session status.
[0031] This application proactively queries the remaining session time and synchronously obtains a dynamic session update threshold at preset intervals during POS terminal operation. This allows for early detection of impending session expiration, preventing transaction interruptions due to session timeout. The remaining time is then compared with the dynamic session update threshold, enabling flexible adjustment of the triggering timing based on actual operating scenarios. This avoids premature or delayed renewal checks, adapting to different transaction statuses. Next, when the remaining session time is less than the dynamic session update threshold, a credibility score is performed on the POS terminal's identity data. This security assessment, preceding the session update operation, effectively prevents unauthorized terminals from obtaining new session credentials. Finally, when the credibility score reaches a preset security threshold, a new session login request is sent to the server. The server then performs identity verification and session creation based on the request, updates its local session state upon receiving the server's response, ensuring the new session's legitimacy and validity, further enhancing payment transaction security.
[0032] In step S103 above, for a detailed implementation method of scoring the credibility of the POS terminal's identity data based on the current transaction status, please refer to [link to relevant documentation]. Figure 2 As shown, Figure 2 A flowchart illustrating an embodiment of the session auto-update method provided in this application for performing credibility scoring, the embodiment including: S201. Determine whether the POS terminal is currently conducting a payment transaction; In this embodiment, before performing a credibility score on the identity data of the POS terminal, recent payment operation records are first obtained from the current session context to determine whether there are any initiated but not yet completed transaction transactions. Next, the processing status of these transaction transactions is checked, specifically by identifying whether the transaction records contain a status marker indicating that the transaction is in progress. If there are records with a status of "authorization pending" or "interacting with the payment network," it is confirmed that a payment transaction is currently in progress, and step S206 is executed. If all recent transaction transactions are in a completed, canceled, or closed state, it is confirmed that there is no ongoing payment transaction, and step S202 is executed.
[0033] S202. Compare the current hardware characteristics of the POS terminal with the initial hardware characteristics to obtain the device matching degree; In this embodiment, after confirming that there are no ongoing payment transactions on the POS terminal, the MAC address of the network interface, the CPU serial number of the motherboard, and the serial number of the memory are first read from the current operating environment of the POS terminal. These three fields are then concatenated to form the current hardware feature set. Simultaneously, the initial hardware feature set saved during the initial activation and registration of the terminal is extracted from the secure storage area. This initial feature set also consists of the MAC address, CPU serial number, and memory serial number. Then, each field is compared. For the MAC address and memory serial number, a complete match check is used; if the strings are exactly the same, the field is considered a match. For the CPU serial number, considering that firmware upgrades and other factors may cause slight changes to the serial number, a preset percentage of character difference tolerance is allowed during comparison. The matching results of each field are recorded as corresponding sub-match scores. Finally, the three sub-match scores are comprehensively calculated according to their respective preset field weights to generate a device matching score out of 100, reflecting the degree of compatibility between the current hardware and the initially registered hardware.
[0034] S203. Detect whether the public network address of the POS terminal is in the preset trusted network address whitelist, and obtain the trustworthiness of the public network address; In this embodiment, after obtaining the device matching score, a standard request message is first sent to the public network address query service to extract the IPv4 address string in dotted decimal format from the returned response. Then, this address is compared one by one with a pre-configured trusted network address whitelist in the secure storage area. The whitelist is pre-configured with the public network addresses and address ranges of all legitimate business locations of the merchant. For example, the fixed public network addresses of each chain store are stored in the form of complete records or address ranges in CIDR format. During the comparison, an exact match is performed first. If the current address matches a complete address record in the whitelist, the public network address is directly marked as trusted. If the exact match does not match, a range match is performed to calculate whether the current address falls within the address range defined in the whitelist. Once it is confirmed that the current address exists in the whitelist, the public network address is recorded as a trusted score. If neither the exact match nor the range match matches any whitelist record, the public network address is recorded as an untrusted score.
[0035] S204. Compare the current operating mode of the POS terminal with the historical operating modes to obtain the behavior deviation degree; In this embodiment, after obtaining the credibility of the public network address, the function usage records within a recent preset time period are first extracted from the operation log. The call counts of various functional modules such as cashiering, refunds, reports, and queries are statistically analyzed according to operation type to calculate the current operation frequency distribution. Simultaneously, the entire day is divided into several time intervals, and the frequency proportion of each type of operation within each time interval is recorded to form the current operation time interval distribution. Then, the historical operation frequency distribution and historical operation time interval distribution of the terminal, statistically analyzed and saved over a longer period, are read from the historical behavior baseline database. For comparison, the absolute value of the difference between the current frequency distribution and the historical frequency distribution for each corresponding module is subtracted from the absolute value of the difference. This value is then summed for all modules to obtain the frequency deviation component. Next, the absolute value of the difference between the current time interval distribution and the historical time interval distribution is calculated for each corresponding interval and summed to obtain the deviation component for the current time interval. Finally, the frequency deviation component and the time interval deviation component are weighted and summed according to preset weighting coefficients to obtain a comprehensive behavior deviation value.
[0036] S205. The device matching degree, public network address credibility, and behavior deviation degree are weighted and integrated according to preset weights to obtain a credibility score. In this embodiment, when performing credibility scoring, the behavioral deviation score is first converted into a behavioral compliance score. The conversion method involves subtracting the behavioral deviation score from the full score, ensuring that the converted value aligns with the device matching score and public IP address credibility. Subsequently, the device matching score, public IP address credibility, and the converted behavioral compliance score are weighted and fused according to preset weights, and the credibility score is calculated using the following formula: ; Wherein, S represents the credibility score, a percentage value with a maximum score of 100; D represents the device matching degree, a percentage score obtained by comparing the current hardware characteristics with the initial hardware characteristics; I represents the public network address credibility, a percentage score obtained by comparing the current network exit address with the whitelist; B represents the behavior deviation degree, a percentage deviation value obtained by comparing the current operation mode with the historical operation mode, with a higher deviation degree indicating more abnormal behavior. w1 represents the weight coefficient of device matching degree, with a value of 0.4; w2 represents the weight coefficient of public network address credibility, with a value of 0.3; w3 represents the weight coefficient of behavior conformity, with a value of 0.3.
[0037] S206. Continuously monitor the transaction status until the transaction is completed, and then score the credibility of the identity data of the POS terminal.
[0038] In this embodiment, after confirming that a payment transaction is in progress on the POS terminal, the credibility scoring process for the POS terminal's identity data is not immediately initiated. Instead, a continuous transaction status monitoring mechanism is first activated, periodically querying the payment transaction's running status at fixed time intervals and obtaining the transaction's progress and completion status in real time. This monitoring continues until the payment transaction process is detected to be complete, the final payment result is generated, and written into the transaction log. Only then does the monitoring end, and the credibility scoring process for the terminal's identity data is formally initiated, sequentially performing operations such as hardware feature comparison, public network address verification, operation mode comparison, and weighted fusion calculation.
[0039] This embodiment checks for ongoing payment transactions before triggering renewal, avoiding processing delays or interruptions caused by verification operations during transactions, thus ensuring the smooth operation of core business. Upon confirming no transactions, the POS terminal's identity data is quantitatively scored from three independent dimensions: device hardware characteristics, network egress address, and operational behavior patterns. This makes it difficult for forgery or anomalies in a single dimension to pass overall verification; attackers must simultaneously breach the triple defenses of device fingerprints, trusted network whitelists, and behavioral patterns. Then, a weighted fusion is used to obtain a comprehensive credibility score, making the security assessment more scientific and reasonable, and reducing the probability of false positives from single-dimensional verification. For cases where an ongoing transaction is detected, a delayed verification strategy is adopted, continuously monitoring the transaction status until the transaction is completed before initiating the identity scoring process. This ensures uninterrupted transactions while guaranteeing thorough security verification for each renewal, effectively balancing security protection and user experience.
[0040] For a detailed implementation of updating the local session state based on the execution result in step S105 above, please refer to [link to relevant documentation]. Figure 3 As shown, Figure 3A flowchart illustrating an embodiment of the automatic session update method provided in this application for updating the local session state, the embodiment including: S301. Determine if the execution result is a successful login to a new session; In this embodiment, after receiving the execution result returned by the server for the new login session request, the core fields such as the login response status code, new session credentials, and session validity period are first extracted from the execution result. Simultaneously, the data format and length of each field are verified to conform to the preset communication protocol specifications. Then, the extracted login response status code is compared one by one with the locally stored successful login status identifier, and the completeness and validity of required fields such as the new session credentials are checked simultaneously. When the login response status code and the successful login status identifier match perfectly, and all required fields are complete and formatted correctly, the new login session is determined to be successful, and step S302 is executed. When the login response status code and the successful login status identifier do not match, or there are missing fields or abnormal data, the new login session is determined to be unsuccessful, and step S303 is executed.
[0041] S302. Update the local session state based on the execution result; In this embodiment, after successfully logging into a new session, the core session parameters, such as the session identifier, session validity period, and session expiration timestamp, are extracted from the execution result returned by the server. Then, the designated storage area for local session state data is located, the existing session state data is cleared, and the extracted new session parameters are completely written to the corresponding storage location. Next, the local session state flag is updated to set the current session state to valid, and the timer for the remaining session time is reset. Finally, the operation information for this session update is written to the local runtime log, thus completing the local session state update process.
[0042] S303. Determine whether the number of times a new login session request is sent to the server is lower than a preset threshold. In this embodiment, after determining that a new session login has failed, the cumulative number of new session login requests sent during the current renewal process is first read from the local record. This number is updated synchronously with each new session login request sent to the server. Then, the read cumulative number of sends is compared with a preset threshold, which is exemplarily set to three. It should be noted that the specific value of the preset threshold can be flexibly configured according to the actual network environment and security policy. For example, in scenarios with frequent network fluctuations, the threshold can be appropriately increased to improve the automatic recovery success rate; in scenarios with high security requirements, the threshold can be appropriately decreased to trigger manual intervention as soon as possible. The specific value of the preset threshold is not limited here. If the cumulative number of sends is lower than the preset threshold, step S304 is executed; if the cumulative number of sends reaches the preset threshold, step S305 is executed.
[0043] S304. Resend the login session request to the server based on the login credentials; In this embodiment, when it is determined that the number of times a new login session request has been sent to the server is less than three, a timer is first set for a preset ten-second interval. After the waiting period ends, the terminal retrieves the pre-stored login credentials from its local secure storage area and reconstructs the new login session request message according to the established communication protocol specifications. Then, the reconstructed new login session request is sent to the corresponding server, and the count value of the new login session request sent for this renewal process is incremented once. After completing the request sending operation, the terminal enters a response listening state and continuously waits for the server to return the corresponding execution result.
[0044] S305. Pause the new session update, notify the client to manually log in to obtain a manual login session, and update the local session state according to the manual login session.
[0045] In this embodiment, when it is determined that the number of times a new login session request has been sent to the server has reached the three-time limit, the automatic renewal process is terminated, the new session update is paused, and a notification is pushed to the user's terminal through the display interface, informing them that the automatic login session has failed and guiding the user to manually enter their identity credentials to obtain a manual login session. After the user completes the manual login and obtains the complete data of the manual login session, the core parameters corresponding to the manual login session, such as the session identifier, validity period, and expiration timestamp, are extracted and written to the local session storage area. This completes the update of the local session status of the manual login session, and at the same time, the relevant information of this renewal failure is written to the local operation log.
[0046] This embodiment judges the execution result of logging into a new session and updates the local session state directly based on the execution result when the login is successful, quickly completing the local synchronization of session renewal and ensuring that the terminal session state is consistent with the server. When the login fails, it checks whether the current number of retries is less than the preset limit of three, thus introducing a limited retry strategy. This provides a recovery opportunity for temporary failures such as network fluctuations or brief server unavailability, while avoiding the continuous pressure on terminal resources and the server caused by unlimited retries. When the number of retries has not reached the limit, the request is resent using the original login credentials, preserving the possibility of automatic recovery. When the number of retries is exhausted and still unsuccessful, the automatic update process is promptly suspended, and the user is notified to log in manually as a fallback. This ensures that even if the automatic mechanism fails, the session update can still be completed through manual intervention, avoiding a prolonged state of no valid session.
[0047] In step S101 above, during the operation of the POS terminal, the specific implementation method for querying the remaining time of the current session according to a preset time period and obtaining the dynamic session update threshold can be found in [reference needed]. Figure 4 As shown, Figure 4 A flowchart illustrating an embodiment of the automatic session update method provided in this application for obtaining a dynamic session update threshold, the embodiment including: S401. During the POS terminal startup process, obtain the total session duration, session query response time, transaction status, and business time period. In this embodiment, when querying the remaining time of the current session according to a preset time period, the total session duration of the current session is simultaneously read from the local session configuration parameters. This duration, in minutes, represents the complete valid time span of the session from its creation time to its natural expiration time. Then, when querying the remaining time of the current session according to the preset time period, the round-trip time from sending the query request to receiving the response is recorded, thus obtaining the session query response time in milliseconds. Subsequently, the current transaction status is obtained through transaction status detection to determine whether any payment transactions are in progress. Next, the system clock is read, and the current time is compared with the preset time period division rules to determine the current business time period category. It should be noted that the time period division rules divide the entire day into three categories: 12:00-14:00 and 18:00-20:00 are peak periods, 23:00-06:00 the next day is the night period, and the remaining time periods are normal periods. For example, if the current time is 13:00, it is classified as peak time; if the current time is 03:00, it is classified as nighttime; and if the current time is 10:00, it is classified as normal time. This completes the collection of four basic parameters: total session duration, session query response time, transaction status, and business time period.
[0048] S402. Calculate the first session update threshold based on the preset relative session threshold and the total session duration; In this embodiment, after obtaining the total session duration, a pre-stored relative session threshold is extracted from the storage area. The relative session threshold is set to 0.1, indicating that renewal is triggered when the remaining session time drops to 10% of the total session duration. Then, the total session duration is multiplied by the preset relative session threshold, using the following formula: ; Where T1 represents the first session update threshold, and T_total represents the total session duration. For example, if the total session duration is 120 minutes, then the first session update threshold is calculated as 12 minutes.
[0049] S403. Set the minimum value between the first session update threshold and the preset session absolute threshold as the second session update threshold; In this embodiment, after obtaining the first session update threshold, a preset session absolute threshold is extracted from the storage area. This session absolute threshold ranges from 1 to 10 minutes, and the specific value can be set according to the actual application scenario; no specific limitation is imposed here. Then, the first session update threshold is compared with the preset session absolute threshold, and the smaller value is taken as the second session update threshold. For example, if the first session update threshold is 12 minutes and the preset session absolute threshold is 5 minutes, the smaller value of 5 minutes is taken, and the second session update threshold is set to 5 minutes. If the first session update threshold is 3 minutes, which is less than the preset session absolute threshold of 5 minutes, then 3 minutes is taken as the second session update threshold.
[0050] S404. Calculate the network quality of the current session based on the session query response time to obtain the first adjustment factor; In this embodiment, after obtaining the session query response time, the session query response time is matched with a preset network quality grading range. The network quality grading range is divided into three levels: a response time less than 200 milliseconds is considered excellent network quality, a response time between 200 and 500 milliseconds is considered normal network quality, and a response time greater than 500 milliseconds is considered poor network quality. Next, based on the matched network quality level, the corresponding first adjustment factor value is read from the storage area. For excellent network quality, the first adjustment factor is 0.8 (indicating delay, with the threshold reduced to 80% of the baseline); for normal network quality, it is 1.0 (representing the baseline); and for poor network quality, it is a specific value between 1.5 and 2.0 (indicating advance, with the threshold amplified by 50%-100% relative to the baseline to combat network jitter). The specific value can be set within this range according to the degree of network poorness and is not specifically limited here.
[0051] It should be noted that the larger the adjustment factor (such as the first adjustment factor here and the second and third adjustment factors below), the earlier the renewal is initiated; the smaller the adjustment factor, the later the renewal is initiated.
[0052] S405. Match the transaction status with the preset transaction status threshold, and determine the second adjustment factor based on the matching result; In this embodiment, after obtaining the current transaction status of the session, a preset transaction status threshold is first read. This preset transaction status threshold is divided into two levels: the second adjustment factor for a no-transaction status is 1.0 (representing the baseline), indicating that it will not affect subsequent threshold adjustments; the second adjustment factor for a transaction-active status is 0.5 (representing a delay, with the threshold reduced to 50% of the baseline, waiting for the transaction to complete). Then, the current transaction status is compared with the two threshold levels. If there is no ongoing payment transaction, it is determined to match the no-transaction level, and the corresponding second adjustment factor is set to 1.0; if there is an ongoing payment transaction, it is determined to match the transaction-active level, and the corresponding second adjustment factor is set to 0.5. This completes the matching of the transaction status with the preset transaction status threshold and the determination of the second adjustment factor.
[0053] S406. Match the business period with the preset period threshold, and determine the third adjustment factor based on the matching result; In this embodiment, after obtaining the current session's business time period, the business time period is first matched with a preset time period threshold to determine the time period category to which the current time belongs. During matching, if the current time falls within the 12:00-14:00 or 18:00-20:00 range, the matching result is a peak time period; if the current time falls within the 23:00-06:00 of the next day range, the matching result is a nighttime time period; if the current time falls outside the above ranges, the matching result is a normal time period. For example, if the current time is 13:00, the matching result is a peak time period; if the current time is 03:00, the matching result is a nighttime time period; if the current time is 10:00, the matching result is a normal time period. After determining the matching results, the adjustment factor corresponding to the matching result of the business time period is located from the configuration parameters. The third adjustment factor for peak time periods is 1.5 (meaning 50% earlier to ensure peak stability), the third adjustment factor for ordinary time periods is 1.0 (representing the baseline), and the third adjustment factor for nighttime time periods is 0.8 (meaning delayed, with the threshold reduced to 80% of the baseline for energy saving during off-peak hours). This completes the determination of the third adjustment factor.
[0054] S407. The second session update threshold is corrected based on the first adjustment factor, the second adjustment factor and the third adjustment factor to obtain the dynamic session update threshold.
[0055] In this embodiment, after obtaining the first adjustment factor, the second adjustment factor, and the third adjustment factor, the second session update threshold, the first adjustment factor, the second adjustment factor, and the third adjustment factor are multiplied together to obtain the dynamic session update threshold. For example, if the second session update threshold is 5 minutes, the first adjustment factor is 1.0, the second adjustment factor is 0.5, and the third adjustment factor is 0.8, then the dynamic session update threshold is calculated as 5 × 1.0 × 0.5 × 0.8 = 2 minutes. It should be noted that the first adjustment factor, the second adjustment factor, and the third adjustment factor each act independently on the threshold, and their directions do not cancel each other out.
[0056] This embodiment collects four parameters simultaneously—total session duration, network response time, transaction status, and business time period—when querying the remaining time of the current session according to a preset time cycle, providing a comprehensive data foundation for dynamic threshold adjustment. Then, a second session update threshold is generated through a dual constraint strategy of minimizing both relative and absolute thresholds. This ensures that the basic triggering timing is neither too late due to a short total session duration nor too early due to a long total session duration, establishing a reasonable baseline triggering point. Next, corresponding adjustment factors are generated from three independent dimensions: network quality, transaction status, and business time period. The adjustment factor is larger when the network is worse to advance the renewal period, and smaller when there is a transaction to delay the renewal period until the transaction is completed. Different adjustment factors are matched to different business time periods according to the actual needs of peak, normal, and nighttime periods. Finally, the product of the three adjustment factors is used as the final correction coefficient to adjust the second session update threshold, resulting in a dynamic session update threshold. This dynamic session update threshold can adapt to network fluctuations, transaction protection requirements, and business characteristics at different times, reducing invalid session refreshes during transaction interruptions and network congestion periods, and improving the continuity of POS terminal transactions and the efficiency of backend session management.
[0057] Please see Figure 5 This application provides a session auto-update device, comprising: The query unit 501 is used to query the remaining time of the current session according to a preset time period during the operation of the POS terminal, and to obtain the dynamic session update threshold. The first judgment unit 502 is used to determine whether the remaining time is less than the dynamic session update threshold. The second judgment unit 503 is used to perform a credibility score on the identity data of the POS terminal based on the current transaction status when the first judgment unit determines that the remaining session time is less than the dynamic session update threshold, and to determine whether the credibility score is lower than the preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. The sending unit 504 is used to send a new login session request to the server based on the login credentials of the POS terminal when the second judgment unit determines that the credibility score is not lower than the preset security threshold, so that the server can perform identity verification and session creation based on the new login session request after receiving the new login session request and obtain the execution result. The execution unit 505 is used to receive the execution result and update the local session state based on the execution result.
[0058] Optionally, the second judgment unit 503 is specifically used for: Determine whether the POS terminal is currently conducting a payment transaction; If not, the current hardware characteristics of the POS terminal are compared with the initial hardware characteristics to obtain the device matching degree; The system checks whether the public IP address of the POS terminal is within the preset trusted network address whitelist to obtain the trustworthiness of the public IP address. The current operating mode of the POS terminal is compared with the historical operating mode to obtain the behavior deviation degree; The device matching degree, public network address credibility, and behavior deviation are weighted and integrated according to preset weights to obtain a credibility score.
[0059] Optionally, the second judgment unit 503 is also specifically used for: If so, the transaction status will be continuously monitored until the transaction is completed, and then the credibility score of the identity data of the POS terminal will be calculated.
[0060] Optionally, execution unit 505 is specifically used for: Determine if the execution result indicates a successful login to a new session; If so, update the local session state based on the execution result; If not, determine whether the number of times a new login session request has been sent to the server is lower than a preset threshold. If so, a new login session request will be resent to the server based on the login credentials; If not, pause new session updates, notify the user to manually log in to obtain a manual login session, and update the local session state based on the manual login session.
[0061] Optionally, query unit 501 is specifically used for: During the POS terminal startup process, obtain the total session duration, session query response time, transaction status, and business time period; The first session update threshold is calculated based on the preset relative session threshold and the total session duration; The minimum value between the first session update threshold and the preset absolute session threshold is set as the second session update threshold; The network quality of the current session is calculated based on the session query response time to obtain the first adjustment factor; The transaction status is matched with a preset transaction status threshold, and a second adjustment factor is determined based on the matching result; The business period is matched with a preset period threshold, and a third adjustment factor is determined based on the matching result; The second session update threshold is corrected based on the first adjustment factor, the second adjustment factor, and the third adjustment factor to obtain the dynamic session update threshold.
[0062] Optionally, a monitoring unit 506 may also be included, specifically for: If not, continue to query the remaining time of the current session according to the preset time period until the remaining time of the current session is less than the dynamic session update threshold.
[0063] Optionally, a notification unit 507 is also included, specifically for: If the credibility score is lower than the preset security threshold, the new session update is paused, and the user is notified to log in manually to obtain a manual login session. The local session status is then updated based on the manual login session.
[0064] Please see Figure 6 This application also provides a session auto-update device, comprising: Processor 601, memory 602, input / output unit 603, bus 604; The processor 601 is connected to the memory 602, the input / output unit 603, and the bus 604; The memory 602 stores a program, and the processor 601 calls the program to execute any of the methods described above.
[0065] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the methods described above.
[0066] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0067] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0068] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0069] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0070] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for automatic session update, characterized in that, The method includes: During the operation of the POS terminal, the remaining time of the current session is queried according to the preset time period, and the dynamic session update threshold is obtained; Determine whether the remaining time is less than the dynamic session update threshold; If so, the credibility score of the identity data of the POS terminal is calculated based on the current transaction status, and it is determined whether the credibility score is lower than a preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. If the credibility score is not lower than the preset security threshold, then a new login session request is sent to the server based on the login credentials of the POS terminal, so that after receiving the new login session request, the server performs identity verification and session creation based on the new login session request and obtains the execution result; Receive the execution result and update the local session state based on the execution result.
2. The automatic session update method according to claim 1, characterized in that, The step of scoring the credibility of the POS terminal's identity data based on the current transaction status includes: Determine whether the POS terminal is currently conducting a payment transaction; If not, the current hardware characteristics of the POS terminal are compared with the initial hardware characteristics to obtain the device matching degree; The credibility of the public network address is obtained by detecting whether the public network address of the POS terminal is in the preset trusted network address whitelist. The current operating mode of the POS terminal is compared with the historical operating modes to obtain the behavior deviation degree; The device matching degree, the public network address credibility, and the behavior deviation degree are weighted and fused according to preset weights to obtain a credibility score.
3. The automatic session update method according to claim 2, characterized in that, After determining whether the POS terminal is conducting a payment transaction, the method further includes: If so, the transaction status will be continuously monitored until the transaction is completed, and then the credibility score of the identity data of the POS terminal will be calculated.
4. The automatic session update method according to claim 1, characterized in that, The step of updating the local session state based on the execution result includes: Determine whether the execution result indicates a successful login to a new session; If so, update the local session state based on the execution result; If not, determine whether the number of times the new login session request has been sent to the server is less than a preset threshold. If so, then the new login session request is resent to the server based on the login credentials; If not, pause new session updates, notify the user to manually log in to obtain a manual login session, and update the local session state based on the manual login session.
5. The automatic session update method according to claim 1, characterized in that, The process of obtaining the dynamic session update threshold includes: During the POS terminal startup process, obtain the total session duration, session query response time, transaction status, and business time period; The first session update threshold is calculated based on the preset relative session threshold and the total session duration; The minimum value between the first session update threshold and the preset absolute session threshold is set as the second session update threshold; The network quality of the current session is calculated based on the session query response time to obtain the first adjustment factor; The transaction status is matched with a preset transaction status threshold, and a second adjustment factor is determined based on the matching result; The business period is matched with a preset period threshold, and a third adjustment factor is determined based on the matching result; The second session update threshold is corrected based on the first adjustment factor, the second adjustment factor, and the third adjustment factor to obtain the dynamic session update threshold.
6. The automatic session update method according to claim 1, characterized in that, After determining whether the remaining time is less than the dynamic session update threshold, the method further includes: If not, continue to query the remaining time of the current session according to the preset time period until the remaining time of the current session is less than the dynamic session update threshold.
7. The session automatic update method according to any one of claims 1 to 6, characterized in that, After determining whether the credibility score is lower than a preset security threshold, the method further includes: If the credibility score is lower than the preset security threshold, the new session update is paused, and the user is notified to log in manually to obtain a manual login session. The local session status is then updated based on the manual login session.
8. A session automatic update device, characterized in that, The device includes: The query unit is used to query the remaining time of the current session according to a preset time period during the operation of the POS terminal, and to obtain the dynamic session update threshold. The first judgment unit is used to determine whether the remaining time is less than the dynamic session update threshold; The second judgment unit is used to perform a credibility score on the identity data of the POS terminal based on the current transaction status when the first judgment unit determines that the remaining session time is less than the dynamic session update threshold, and to determine whether the credibility score is lower than a preset security threshold. The identity data includes the hardware characteristics, public network address and operation mode of the POS terminal. The sending unit is configured to send a new login session request to the server based on the login credentials of the POS terminal when the second judgment unit determines that the credibility score is not lower than the preset security threshold, so that the server, after receiving the new login session request, performs identity verification and session creation based on the new login session request and obtains the execution result; An execution unit is used to receive the execution result and update the local session state based on the execution result.
9. A session automatic update device, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains a program that, when executed on a computer, performs the method as described in any one of claims 1 to 7.
