[go: up one dir, main page]

CN118214610B - Login state maintaining method and system - Google Patents

Login state maintaining method and system Download PDF

Info

Publication number
CN118214610B
CN118214610B CN202410488872.0A CN202410488872A CN118214610B CN 118214610 B CN118214610 B CN 118214610B CN 202410488872 A CN202410488872 A CN 202410488872A CN 118214610 B CN118214610 B CN 118214610B
Authority
CN
China
Prior art keywords
cookie
login
terminal
request
heartbeat
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410488872.0A
Other languages
Chinese (zh)
Other versions
CN118214610A (en
Inventor
占家宝
范从明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Shenzhou Yunhe Data Technology Development Co ltd
Original Assignee
Beijing Shenzhou Yunhe Data Technology Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Shenzhou Yunhe Data Technology Development Co ltd filed Critical Beijing Shenzhou Yunhe Data Technology Development Co ltd
Priority to CN202410488872.0A priority Critical patent/CN118214610B/en
Publication of CN118214610A publication Critical patent/CN118214610A/en
Application granted granted Critical
Publication of CN118214610B publication Critical patent/CN118214610B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0815Network architectures or network communication protocols for network security for authentication of entities providing single-sign-on or federations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0807Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明涉及互联网领域,提供一种登录状态保持方法及系统,其中登录状态保持方法包括:与登录终端进行交互,生成与登录终端匹配的cookie;接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。用以解决现有技术中由于网络的波动情况,很难保证用户随时随地都可以顺利登录办公系统的缺陷,能够维持用户的登录状态,利用有限的服务器资源实现智能办公处理。

The present invention relates to the field of the Internet, and provides a method and system for maintaining a login status, wherein the method for maintaining a login status comprises: interacting with a login terminal to generate a cookie matching the login terminal; receiving a cookie saving request from the login terminal, and placing the cookie saving request in an asynchronous queue; the login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie. The method is used to solve the defect in the prior art that it is difficult to ensure that users can successfully log in to an office system anytime and anywhere due to network fluctuations, and can maintain the login status of users, and realize intelligent office processing using limited server resources.

Description

登录状态保持方法及系统Login status maintenance method and system

技术领域Technical Field

本发明涉及互联网技术领域,尤其涉及一种登录状态保持方法及系统。The present invention relates to the field of Internet technology, and in particular to a method and system for maintaining a login status.

背景技术Background Art

用户在登录办公系统之时,由于网络的波动情况,很难保证随时随地都可以顺利登录,另外部分办公系统的服务器端为了服务的稳定性,通常会限制同一用户的登录次数,避免多次频繁登录,在这样的前提下,很有可能会影响用户的正常办公。When users log in to the office system, it is difficult to ensure that they can log in smoothly anytime and anywhere due to network fluctuations. In addition, for the sake of service stability, the server side of some office systems usually limits the number of logins for the same user to avoid multiple frequent logins. Under such circumstances, it is very likely to affect the user's normal work.

基于此,现在亟需一种能够维持用户的登录状态,利用有限的服务器资源实现智能办公处理的方案。Based on this, there is an urgent need for a solution that can maintain the user's login status and use limited server resources to achieve intelligent office processing.

发明内容Summary of the invention

本发明提供一种登录状态保持方法及系统,用以解决现有技术中由于网络的波动情况,很难保证用户随时随地都可以顺利登录办公系统的缺陷,能够维持用户的登录状态,利用有限的服务器资源实现智能办公处理。The present invention provides a login status maintaining method and system, which are used to solve the defect in the prior art that it is difficult to ensure that users can successfully log in to the office system anytime and anywhere due to network fluctuations. The method and system can maintain the user's login status and realize intelligent office processing by using limited server resources.

本发明提供一种登录状态保持方法,包括:The present invention provides a method for maintaining a login status, comprising:

与登录终端进行交互,生成与登录终端匹配的cookie;Interact with the login terminal and generate a cookie that matches the login terminal;

接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;Receive the cookie saving request from the login terminal and put the cookie saving request into the asynchronous queue;

登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

根据本发明提供的登录状态保持方法,生成与登录终端匹配的cookie之后,还包括:According to the login status maintaining method provided by the present invention, after generating a cookie matching the login terminal, the method further includes:

对cookie进行校验,校验通过后,将cookie存入登录终端。Verify the cookie, and if the verification passes, store the cookie in the login terminal.

根据本发明提供的登录状态保持方法,接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中,包括:According to the login status maintaining method provided by the present invention, a cookie saving request from a login terminal is received, and the cookie saving request is placed in an asynchronous queue, including:

接收登录终端的心跳请求,并向登录终端发送回复指令,以维持与登录终端的心跳连接。Receive the heartbeat request from the login terminal and send a reply instruction to the login terminal to maintain the heartbeat connection with the login terminal.

根据本发明提供的登录状态保持方法,cookie保存请求为API保持请求,登录终端的心跳请求为非堵塞请求。According to the login status maintaining method provided by the present invention, the cookie saving request is an API maintaining request, and the heartbeat request of the login terminal is a non-blocking request.

根据本发明提供的登录状态保持方法,cookie保存请求为driver保持请求,登录终端通过不断刷新来发送心跳请求。According to the login status maintaining method provided by the present invention, the cookie saving request is a driver maintaining request, and the login terminal sends a heartbeat request by continuously refreshing.

根据本发明提供的登录状态保持方法,登录终端随机间隔N分钟发送心跳请求,直至无法接收到回复指令。According to the login status maintaining method provided by the present invention, the login terminal sends a heartbeat request at random intervals of N minutes until no reply instruction is received.

根据本发明提供的登录状态保持方法,还包括:The method for maintaining the login status according to the present invention further includes:

通过异步日志对登录状态进行记录。The login status is recorded through asynchronous logs.

本发明还提供一种登录状态保持系统,包括:The present invention also provides a login status maintaining system, comprising:

生成模块,用于与登录终端进行交互,生成与登录终端匹配的cookie;A generation module, used to interact with the login terminal and generate a cookie matching the login terminal;

接收模块,用于接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;The receiving module is used to receive the cookie saving request from the login terminal and put the cookie saving request into the asynchronous queue;

保持模块,用于登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The maintenance module is used for the login terminal to save the cookie. The login terminal maintains the login status of the login terminal based on the cookie.

本发明还提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行程序时实现如上述任一种登录状态保持方法。The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned methods for maintaining a login status is implemented.

本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种登录状态保持方法。The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned login status maintaining methods is implemented.

本发明还提供一种计算机程序产品,包括计算机程序,计算机程序被处理器执行时实现如上述任一种登录状态保持方法。The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, any of the above-mentioned login status maintaining methods is implemented.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

图1是本发明实施例提供的登录状态保持方法的流程示意图之一;FIG1 is a flow chart of a method for maintaining a login status according to an embodiment of the present invention;

图2是本发明实施例提供的登录状态保持系统的结构示意图;2 is a schematic diagram of the structure of a login status maintaining system provided in an embodiment of the present invention;

图3是本发明实施例提供的登录状态保持方法的流程示意图之二;3 is a second flow chart of a method for maintaining a login status according to an embodiment of the present invention;

图4是本发明实施例提供的登录状态保持方法的流程示意图之三;4 is a third flow chart of a method for maintaining a login status according to an embodiment of the present invention;

图5是本发明实施例提供的登录状态保持方法的流程示意图之四;5 is a fourth flow chart of a method for maintaining a login status according to an embodiment of the present invention;

图6是本发明实施例提供的登录状态保持方法的流程示意图之五;6 is a flowchart of a method for maintaining a login status according to an embodiment of the present invention;

图7是本发明实施例提供的电子设备的结构示意图。FIG. 7 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

具体实施方式DETAILED DESCRIPTION

为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明中的附图,对本发明中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

图1是本发明实施例提供的登录状态保持方法的流程示意图之一。FIG. 1 is a flow chart of a method for maintaining a login status according to an embodiment of the present invention.

如图1所示,本实施例提供了一种登录状态保持方法,包括:As shown in FIG1 , this embodiment provides a method for maintaining a login status, including:

步骤101,与登录终端进行交互,生成与登录终端匹配的cookie;Step 101, interacting with a login terminal to generate a cookie matching the login terminal;

步骤102,接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;Step 102, receiving a cookie saving request from the login terminal, and placing the cookie saving request into an asynchronous queue;

步骤103,登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。Step 103: The login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

实际应用中,本实施例提供的登录状态保持方法可以应用于报税领域,具体的,现有技术中,面对复杂多变的网络环境,以及局端报税登录的限制,很难保证用户随时随地都可以登录税务办公系统进行远程报税操作,基于此,本实施例提供的方案可以使用户一次登录之后维持登录状态,利用有限的资源实现智能税务处理。In practical applications, the login status maintenance method provided in this embodiment can be applied to the field of tax reporting. Specifically, in the prior art, facing the complex and changeable network environment and the limitations of tax reporting login at the bureau end, it is difficult to ensure that users can log in to the tax office system anytime and anywhere to perform remote tax reporting operations. Based on this, the solution provided in this embodiment can enable users to maintain the login status after logging in once, and realize intelligent tax processing with limited resources.

其中步骤102中使用异步队列,具有提高并发性以及提高吞吐量的好处,具体的如下:The use of an asynchronous queue in step 102 has the benefits of improving concurrency and throughput, as follows:

在多线程编程中,一个线程完成一项任务可能需要较长时间,如果等待这个线程完成任务后再让下一个线程开始工作,会大大降低程序的并发性。异步队列可以存储待处理的任务,让多个线程同时从队列中取出任务进行处理,提高了并发性,充分利用了多核处理器的计算能力;In multi-threaded programming, it may take a long time for a thread to complete a task. If the next thread starts working after waiting for the thread to complete the task, the concurrency of the program will be greatly reduced. Asynchronous queues can store pending tasks and allow multiple threads to take tasks from the queue for processing at the same time, which improves concurrency and fully utilizes the computing power of multi-core processors.

由于异步队列允许多个线程同时处理任务,因此可以显著提高程序的吞吐量。这对于需要处理大量请求的应用程序来说是非常重要的。Since asynchronous queues allow multiple threads to process tasks simultaneously, the throughput of the program can be significantly improved. This is very important for applications that need to process a large number of requests.

示例性实施例中,生成与登录终端匹配的cookie之后,还包括:In an exemplary embodiment, after generating a cookie matching the login terminal, the method further includes:

对cookie进行校验,校验通过后,将cookie存入登录终端。Verify the cookie, and if the verification passes, store the cookie in the login terminal.

示例性实施例中,接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中,包括:In an exemplary embodiment, receiving a cookie saving request from a login terminal and placing the cookie saving request in an asynchronous queue includes:

接收登录终端的心跳请求,并向登录终端发送回复指令,以维持与登录终端的心跳连接。Receive the heartbeat request from the login terminal and send a reply instruction to the login terminal to maintain the heartbeat connection with the login terminal.

示例性实施例中,cookie保存请求为API保持请求,登录终端的心跳请求为非堵塞请求。In an exemplary embodiment, the cookie preservation request is an API retention request, and the heartbeat request of the login terminal is a non-blocking request.

示例性实施例中,cookie保存请求为driver保持请求,登录终端通过不断刷新来发送心跳请求。In an exemplary embodiment, the cookie saving request is a driver retention request, and the login terminal sends a heartbeat request by continuously refreshing.

示例性实施例中,登录终端随机间隔N分钟发送心跳请求,直至无法接收到回复指令。In an exemplary embodiment, the login terminal sends a heartbeat request at random intervals of N minutes until no reply instruction is received.

示例性实施例中,还包括:In an exemplary embodiment, it further includes:

通过异步日志对登录状态进行记录。The login status is recorded through asynchronous logs.

下面对本发明提供的登录状态保持系统进行描述,下文描述的登录状态保持系统与上文描述的登录状态保持方法可相互对应参照。The login status maintaining system provided by the present invention is described below. The login status maintaining system described below and the login status maintaining method described above can be referenced to each other.

图2是本发明实施例提供的登录状态保持系统的结构示意图。FIG. 2 is a schematic diagram of the structure of a login status maintaining system provided in an embodiment of the present invention.

如图2所示,本实施例提供的登录状态保持系统包括:As shown in FIG2 , the login status maintaining system provided in this embodiment includes:

生成模块201,用于与登录终端进行交互,生成与登录终端匹配的cookie;A generation module 201 is used to interact with a login terminal and generate a cookie matching the login terminal;

接收模块202,用于接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;The receiving module 202 is used to receive a cookie saving request from a login terminal and place the cookie saving request into an asynchronous queue;

保持模块203,用于登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The maintaining module 203 is used for the login terminal to save the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

示例性实施例中,还包括校验模块,校验模块具体用于:对所述cookie进行校验,校验通过后,将所述cookie存入所述登录终端。In an exemplary embodiment, a verification module is also included, and the verification module is specifically used to: verify the cookie, and after the verification passes, store the cookie in the login terminal.

示例性实施例中,接收模块202还用于:接收所述登录终端的心跳请求,并向所述登录终端发送回复指令,以维持与所述登录终端的心跳连接。In an exemplary embodiment, the receiving module 202 is further used to: receive a heartbeat request from the login terminal, and send a reply instruction to the login terminal to maintain a heartbeat connection with the login terminal.

示例性实施例中,所述cookie保存请求为API保持请求,所述登录终端的心跳请求为非堵塞请求。In an exemplary embodiment, the cookie saving request is an API holding request, and the heartbeat request of the login terminal is a non-blocking request.

示例性实施例中,所述cookie保存请求为driver保持请求,所述登录终端通过不断刷新来发送心跳请求。In an exemplary embodiment, the cookie saving request is a driver retention request, and the login terminal sends a heartbeat request by continuously refreshing.

示例性实施例中,所述登录终端随机间隔N分钟发送心跳请求,直至无法接收到回复指令。In an exemplary embodiment, the login terminal sends a heartbeat request at random intervals of N minutes until no reply instruction is received.

示例性实施例中,还包括记录模块,记录模块具体用于:In an exemplary embodiment, a recording module is also included, and the recording module is specifically used for:

通过异步日志对登录状态进行记录。The login status is recorded through asynchronous logs.

本实施例提供的登录状态保持系统的具体实施方法可以参照上述实施例进行实施,此处不再赘述。The specific implementation method of the login status maintaining system provided in this embodiment can be implemented with reference to the above embodiment and will not be described in detail here.

下面提供具体的实施例来说明本申请提供的登录状态保持方法。The following provides a specific embodiment to illustrate the login status maintenance method provided by the present application.

图3是本发明实施例提供的登录状态保持方法的流程示意图之二。FIG. 3 is a second flow chart of the method for maintaining the login status provided in an embodiment of the present invention.

图4是本发明实施例提供的登录状态保持方法的流程示意图之三。FIG. 4 is a third flow chart of the method for maintaining the login status provided in an embodiment of the present invention.

图5是本发明实施例提供的登录状态保持方法的流程示意图之四。FIG. 5 is a fourth flow chart of the method for maintaining the login status provided in an embodiment of the present invention.

图6是本发明实施例提供的登录状态保持方法的流程示意图之五。FIG. 6 is a fifth flowchart of the method for maintaining a login status provided in an embodiment of the present invention.

其中图3是本发明实施例提供的登录状态保持方法的具体流程示意图,图4-图6是本发明实施例提供的三个不同登录方式的实施例的时序图。FIG. 3 is a schematic diagram of a specific flow chart of a method for maintaining a login status according to an embodiment of the present invention, and FIGS. 4 to 6 are timing diagrams of three different login modes according to an embodiment of the present invention.

如图3所示,本实施例提供的登录状态保持方法包括:As shown in FIG3 , the method for maintaining the login status provided in this embodiment includes:

1、获取cookie任务。此步骤中,根据登录终端的不同有不同的获取cookie的方式,具体的,当登录终端为普通的移动终端时,当第一次登录成功后,移动终端与服务器进行交互并保存cookie,同时与服务器保持心跳连接以维持会话状态;当登录终端为固定设备时,可以通过一组机器来管理一个较大的driver池,登录时,每个driver都可以打开登录界面,并将二维码发送至中台进行扫描验证,一旦二维码被用户扫描且登录成功之后,将与服务器进行交互获取以及保存cookie,同时与服务器保持心跳连接。1. Obtain cookie task. In this step, there are different ways to obtain cookies depending on the login terminal. Specifically, when the login terminal is an ordinary mobile terminal, after the first login is successful, the mobile terminal interacts with the server and saves cookies, and maintains a heartbeat connection with the server to maintain the session state; when the login terminal is a fixed device, a larger driver pool can be managed by a group of machines. When logging in, each driver can open the login interface and send the QR code to the middle station for scanning and verification. Once the QR code is scanned by the user and the login is successful, it will interact with the server to obtain and save cookies, and maintain a heartbeat connection with the server.

2、接收登录终端的cookie保存请求并对cookie的一部分字段进行校验,例如当本实施例提供的登录状态保持方法应用于报税服务时,可以校验税号长度是否为18位;2. Receive a cookie saving request from the login terminal and verify some fields of the cookie. For example, when the login status maintenance method provided in this embodiment is applied to tax declaration services, it can be verified whether the tax number length is 18 digits;

3、校验通过之后,将cookie存入redis,并将保持cookie的任务放入异步队列中,异步队列将会分发任务给用于保持cookie心跳的机器群;3. After the verification is passed, the cookie is stored in redis, and the task of keeping the cookie is placed in the asynchronous queue. The asynchronous queue will distribute the task to the machine group used to keep the cookie heartbeat;

4、保持cookie心跳的机器群中的机器在接收到cookie保存请求之后,根据cookie保存请求中cookie类型的不同分为API请求保持和driver保持两种方式,其中对于API请求保持,可以使用aiohttp发送非阻塞请求以保持服务器端的心跳;对于driver保持,可以从预先建立的异步driver池中随机获取一个driver对象,并且driver对象将不断进行刷新,以保持心跳;4. After receiving the cookie save request, the machines in the machine group that maintains the cookie heartbeat are divided into two modes: API request preservation and driver preservation according to the different cookie types in the cookie save request. For API request preservation, aiohttp can be used to send non-blocking requests to maintain the heartbeat of the server; for driver preservation, a driver object can be randomly obtained from the pre-established asynchronous driver pool, and the driver object will be continuously refreshed to maintain the heartbeat;

5、通过随机间隔N分钟的方式进行保持心跳连接,直到心跳连接的时长达到最大时长或者心跳失效则需要重新登录,一旦确定心跳连接达到最大时长或者心跳失效,将释放资源,可以关闭API请求或者释放driver。5. Maintain the heartbeat connection at random intervals of N minutes until the heartbeat connection reaches the maximum duration or the heartbeat fails, then you need to log in again. Once it is determined that the heartbeat connection has reached the maximum duration or the heartbeat fails, the resources will be released, and you can close the API request or release the driver.

6、资源释放完毕之后,可以删除redis中无效的cookie;6. After the resources are released, the invalid cookies in redis can be deleted;

7、可以通过异步日志对上述的整个过程进行记录。7. The entire process mentioned above can be recorded through asynchronous logs.

其中图3中的Playwright有头指的是Playwright在有UI界面的情况下运行浏览器的自动化操作;The Playwright head in Figure 3 refers to Playwright running the browser's automated operation with a UI interface;

Playwright无头指的是Playwright在无UI界面的情况下运行浏览器的自动化操作。Playwright headless means that Playwright runs the browser's automated operations without a UI interface.

如图4所示,本实施例示例了一种通过API方式实现登录状态维持的登录流程,包括:As shown in FIG. 4 , this embodiment illustrates a login process for maintaining the login status through an API, including:

第一次客户端通过RPA进行登录,登录成功之后,携带cookie发送请求至服务端,同时指定刷新模式为API。服务端收到cookie之后,将cookie保存至redis,同时插入一个cookie任务至Mq消息队列。The first time a client logs in through RPA, after successful login, it sends a request to the server with the cookie and specifies the refresh mode as API. After receiving the cookie, the server saves the cookie to redis and inserts a cookie task into the MQ message queue.

Mq消息队列分发任务到刷新机器人,机器人执行API请求定时刷新cookie,直到cookie失效或达到最大保持时间将cookie从redis中删除。The MQ message queue distributes tasks to the refresh robot, and the robot executes API requests to refresh the cookie regularly until the cookie expires or reaches the maximum retention time and deletes the cookie from redis.

第二次客户端直接请求服务器获取cookie,如果cookie有效则直接跳转进待登录的系统,如果cookie无效则继续重复第一次登录的流程。The second time, the client directly requests the server to obtain the cookie. If the cookie is valid, it will directly jump to the system to be logged in. If the cookie is invalid, it will continue to repeat the first login process.

如图5所示,本实施例还示例了一种通过driver实现登录状态维持的登录流程,包括:As shown in FIG. 5 , this embodiment also illustrates a login process for maintaining the login status through a driver, including:

第一次客户端通过RPA进行登录,登录成功之后,携带cookie发送请求至服务端,同时指定刷新模式为driver。服务端收到cookie之后,将cookie保存至redis,同时插入一个cookie任务至Mq消息队列。The first time a client logs in through RPA, after successful login, it sends a request to the server with the cookie and specifies the refresh mode as driver. After receiving the cookie, the server saves the cookie to redis and inserts a cookie task into the MQ message queue.

Mq消息队列分发任务到刷新机器人,机器人执行RPA工具,定时刷新cookie,直到cookie失效或达到最大保持时间将cookie从redis中删除。The MQ message queue distributes tasks to the refresh robot. The robot executes the RPA tool and refreshes the cookie regularly until the cookie expires or reaches the maximum retention time and deletes the cookie from redis.

第二次客户端直接请求服务器获取cookie,如果cookie有效则直接跳转进待登录的系统,如果cookie无效则继续重复第一次登录的流程。The second time, the client directly requests the server to obtain the cookie. If the cookie is valid, it will directly jump to the system to be logged in. If the cookie is invalid, it will continue to repeat the first login process.

如图6所示,本实施例还示例了一种通过二维码登录实现登录状态维持的登录流程,包括:As shown in FIG. 6 , this embodiment also illustrates a login process for maintaining the login status through QR code login, including:

客户在客户端打开RPA工具,传递二维码信息给中台,中台保存二维码等待客户扫码。The customer opens the RPA tool on the client and passes the QR code information to the middle platform. The middle platform saves the QR code and waits for the customer to scan it.

客户端定时检测自身登录状态,当检测到状态变为登录成功,向服务器发送携带cookie的请求,并同时指定刷新模式为api。The client periodically checks its own login status. When it detects that the status has changed to successful login, it sends a request with cookies to the server and specifies the refresh mode as api.

服务端收到cookie,将cookie保存至redis,同时插入一个cookie任务至Mq消息队列。The server receives the cookie, saves it to redis, and inserts a cookie task into the MQ message queue.

Mq队列分发任务到刷新机器人,机器人执行API请求定时刷新cookie,直到cookie失效或达到最大保持时间将cookie从redis中删除。The MQ queue distributes tasks to the refresh robot, and the robot executes API requests to refresh the cookie regularly until the cookie expires or reaches the maximum retention time and deletes the cookie from redis.

图7示例了一种电子设备的实体结构示意图,如图7所示,该电子设备可以包括:处理器(processor)710、通信接口(Communications Interface)720、存储器(memory)730和通信总线740,其中,处理器710,通信接口720,存储器730通过通信总线740完成相互间的通信。处理器710可以调用存储器730中的逻辑指令,以执行登录状态保持方法,该方法包括:FIG7 illustrates a schematic diagram of the physical structure of an electronic device. As shown in FIG7 , the electronic device may include: a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communications interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the login status maintenance method, which includes:

与登录终端进行交互,生成与登录终端匹配的cookie;Interact with the login terminal and generate a cookie that matches the login terminal;

接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;Receive the cookie saving request from the login terminal and put the cookie saving request into the asynchronous queue;

登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

此外,上述的存储器730中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

另一方面,本发明还提供一种计算机程序产品,计算机程序产品包括计算机程序,计算机程序可存储在非暂态计算机可读存储介质上,计算机程序被处理器执行时,计算机能够执行上述各方法所提供的登录状态保持方法,该方法包括:On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the login status maintenance method provided by the above methods, the method includes:

与登录终端进行交互,生成与登录终端匹配的cookie;Interact with the login terminal and generate a cookie that matches the login terminal;

接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;Receive the cookie saving request from the login terminal and put the cookie saving request into the asynchronous queue;

登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

又一方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各方法提供的登录状态保持方法,该方法包括:In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the login status maintaining method provided by the above methods, the method comprising:

与登录终端进行交互,生成与登录终端匹配的cookie;Interact with the login terminal and generate a cookie that matches the login terminal;

接收登录终端的cookie保存请求,将cookie保存请求置入异步队列中;Receive the cookie saving request from the login terminal and put the cookie saving request into the asynchronous queue;

登录终端对cookie进行保存,登录终端基于cookie,保持登录终端的登录状态。The login terminal saves the cookie, and the login terminal maintains the login status of the login terminal based on the cookie.

以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (4)

1.登录状态保持方法,其特征在于,包括:1. A method for maintaining a logged-in status, characterized in that it comprises: 获取cookie任务,当登录终端为普通的移动终端时,当第一次登录成功后,移动终端与服务器进行交互并保存cookie,同时与服务器保持心跳连接以维持会话状态;当登录终端为固定设备时,通过一组机器来管理一个driver池,登录时,每个driver都可以打开登录界面,并将二维码发送至中台进行扫描验证,一旦二维码被用户扫描且登录成功之后,将与服务器进行交互获取以及保存cookie,同时与服务器保持心跳连接;Obtain cookie task. When the login terminal is an ordinary mobile terminal, after the first login is successful, the mobile terminal interacts with the server and saves cookies, and maintains a heartbeat connection with the server to maintain the session state. When the login terminal is a fixed device, a driver pool is managed by a group of machines. When logging in, each driver can open the login interface and send the QR code to the middle station for scanning and verification. Once the QR code is scanned by the user and the login is successful, it will interact with the server to obtain and save cookies, and maintain a heartbeat connection with the server. 接收登录终端的cookie保存请求并对cookie的一部分字段进行校验,应用于报税服务时,校验税号长度是否为18位;Receive the cookie saving request from the login terminal and verify some fields of the cookie. When applied to tax declaration services, verify whether the tax number length is 18 digits; 校验通过之后,将cookie存入redis,并将保持cookie的任务放入异步队列中,异步队列将会分发任务给用于保持cookie心跳的机器群;After the verification is passed, the cookie is stored in redis, and the task of keeping the cookie is put into the asynchronous queue. The asynchronous queue will distribute the task to the machine group used to keep the cookie heartbeat; 保持cookie心跳的机器群中的机器在接收到cookie保存请求之后,根据cookie保存请求中cookie类型的不同分为API请求保持和driver保持两种方式,其中对于API请求保持,使用aiohttp发送非阻塞请求以保持服务器端的心跳;对于driver保持,从预先建立的异步driver池中随机获取一个driver对象,并且driver对象将不断进行刷新,以保持心跳;After receiving a cookie save request, the machines in the machine group that keeps the cookie heartbeat are divided into two modes: API request preservation and driver preservation according to the different cookie types in the cookie save request. For API request preservation, aiohttp is used to send non-blocking requests to keep the heartbeat on the server side; for driver preservation, a driver object is randomly obtained from the pre-established asynchronous driver pool, and the driver object will be continuously refreshed to keep the heartbeat; 通过随机间隔N分钟的方式进行保持心跳连接,直到心跳连接的时长达到最大时长或者心跳失效则需要重新登录,一旦确定心跳连接达到最大时长或者心跳失效,将释放资源,关闭API请求或者释放driver;The heartbeat connection is maintained at random intervals of N minutes until the heartbeat connection reaches the maximum duration or the heartbeat fails, in which case you need to log in again. Once it is determined that the heartbeat connection has reached the maximum duration or the heartbeat fails, resources will be released, and the API request will be closed or the driver will be released. 资源释放完毕之后,删除redis中无效的cookie;After the resources are released, delete the invalid cookies in redis; 通过异步日志对过程进行记录;Record the process through asynchronous logging; 通过API方式实现登录状态维持的登录流程,包括:The login process of maintaining the login status through API includes: 第一次客户端通过RPA进行登录,登录成功之后,携带cookie发送请求至服务端,同时指定刷新模式为API,服务端收到cookie之后,将cookie保存至redis,同时插入一个cookie任务至Mq消息队列;The first time a client logs in through RPA, after successful login, it sends a request to the server with the cookie and specifies the refresh mode as API. After receiving the cookie, the server saves the cookie to redis and inserts a cookie task into the MQ message queue. Mq消息队列分发任务到刷新机器人,机器人执行API请求定时刷新cookie,直到cookie失效或达到最大保持时间将cookie从redis中删除;The MQ message queue distributes tasks to the refresh robot, which executes API requests to refresh the cookie regularly until the cookie expires or reaches the maximum retention time, and then deletes the cookie from redis. 第二次客户端直接请求服务器获取cookie,如果cookie有效则直接跳转进待登录的系统,如果cookie无效则继续重复第一次登录的流程。The second time, the client directly requests the server to obtain the cookie. If the cookie is valid, it will directly jump to the system to be logged in. If the cookie is invalid, it will continue to repeat the first login process. 2.登录状态保持系统,应用于权利要求1所述的登录状态保持方法,其特征在于,包括:2. A login status maintaining system, applied to the login status maintaining method according to claim 1, characterized in that it comprises: 生成模块,用于与登录终端进行交互,生成与所述登录终端匹配的cookie;A generation module, used to interact with the login terminal and generate a cookie matching the login terminal; 接收模块,用于接收所述登录终端的cookie保存请求,将所述cookie保存请求置入异步队列中;A receiving module, used for receiving a cookie saving request from the login terminal, and placing the cookie saving request into an asynchronous queue; 保持模块,用于所述登录终端对所述cookie进行保存,所述登录终端基于所述cookie,保持所述登录终端的登录状态。The maintaining module is used for the login terminal to save the cookie, and the login terminal maintains the login status of the login terminal based on the cookie. 3.一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1所述登录状态保持方法。3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the login status maintaining method as claimed in claim 1 when executing the program. 4.计算机程序产品,包括计算机程序,计算机程序被处理器执行时实现如权利要求1所述登录状态保持方法。4. A computer program product, comprising a computer program, which implements the login status maintaining method as claimed in claim 1 when the computer program is executed by a processor.
CN202410488872.0A 2024-04-23 2024-04-23 Login state maintaining method and system Active CN118214610B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410488872.0A CN118214610B (en) 2024-04-23 2024-04-23 Login state maintaining method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410488872.0A CN118214610B (en) 2024-04-23 2024-04-23 Login state maintaining method and system

Publications (2)

Publication Number Publication Date
CN118214610A CN118214610A (en) 2024-06-18
CN118214610B true CN118214610B (en) 2024-11-05

Family

ID=91455417

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410488872.0A Active CN118214610B (en) 2024-04-23 2024-04-23 Login state maintaining method and system

Country Status (1)

Country Link
CN (1) CN118214610B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118917804B (en) * 2024-08-09 2025-05-27 北京神州云合数据科技发展有限公司 RPA scheduling method, device, equipment and storage medium of tax return system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112689014A (en) * 2020-12-24 2021-04-20 百果园技术(新加坡)有限公司 Double-full-duplex communication method and device, computer equipment and storage medium
CN117575756A (en) * 2023-11-14 2024-02-20 中拍平台网络科技股份有限公司 Network auction bid pushing method, device, computer equipment and medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9866640B2 (en) * 2013-09-20 2018-01-09 Oracle International Corporation Cookie based session management
CN110430205B (en) * 2019-08-09 2023-04-18 深圳前海微众银行股份有限公司 Single sign-on method, device, equipment and computer readable storage medium
CN113852628B (en) * 2021-09-23 2023-09-05 武汉众邦银行股份有限公司 Decentralizing single sign-on method, device and storage medium
CN116232754A (en) * 2023-03-24 2023-06-06 中国建设银行股份有限公司 Method and device for maintaining login state

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112689014A (en) * 2020-12-24 2021-04-20 百果园技术(新加坡)有限公司 Double-full-duplex communication method and device, computer equipment and storage medium
CN117575756A (en) * 2023-11-14 2024-02-20 中拍平台网络科技股份有限公司 Network auction bid pushing method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN118214610A (en) 2024-06-18

Similar Documents

Publication Publication Date Title
CN118214610B (en) Login state maintaining method and system
CN103019651B (en) The method for parallel processing of complex task and device
US9961125B2 (en) Messaging API over HTTP protocol to establish context for data exchange
CN110278187A (en) Multi-terminal single sign-on method, system, synchronization server and medium
CN109246076A (en) A kind of method and apparatus of single-sign-on multisystem
CN108334545A (en) A kind of method and device for realizing asynchronous service
CN115514746B (en) Instant messaging method, device, system, equipment and storage medium
CN101188570A (en) Instant message processing system and method
WO2020006902A1 (en) Batch payment method and apparatus, computer device, and storage medium
CN113064735A (en) Service processing method and device
CN110830512A (en) Multi-platform unified authentication system based on domain account
CN109361778A (en) A kind of method and terminal managing session
CN114528049B (en) A method and system for implementing API call information statistics based on InfluxDB
CN112134707B (en) Concurrent access method and device for multiple KERBEROS clusters
CN115330396A (en) Payment state acquisition method and device, computer equipment and storage medium
CN111190731A (en) Cluster task scheduling system based on weight
CN114363395A (en) Session processing method, device and computer readable storage medium
CN103069741A (en) Credential authentication method and single sign-on server
CN114006939A (en) Message pushing method and device
CN112818016A (en) API-based real-time and off-line data query method and system
CN117527220A (en) Cloud password service method and system
CN111125653A (en) High-concurrency unified authentication method based on Nginx and Redis
CN113704080B (en) Automatic test method and device
CN114339637B (en) Short message splicing method, device, equipment and storage medium
CN112417349B (en) Programming device and network state monitoring method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant