Cookie management method and device, equipment and medium

By integrating the Cookie Manager in the application, merging and updating cookie information on different pages, the problem of inconsistent cookie management between different pages of the application is solved, and the connection inertia and user experience are improved.

CN119961542APending Publication Date: 2025-05-09CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411794802.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

Between different pages of the application, inconsistent cookie management leads to insufficient inertia and low user experience, such as expired cookies lead to re-login, or information cannot be synchronized.

Method used

Provides a cookie management method, integrates it in the application through the Cookie Manager, extracts domain names and cookies when receiving requests, merges the latest cookie information, and updates local cookie files to ensure cookie consistency between different pages.

Benefits of technology

It improves the inertia of connection between different pages, avoids the problems of expired cookies and out-of-synchronization of information, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119961542A_ABST
    Figure CN119961542A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, discloses a Cookie management method and device, equipment and a medium, and is applied to a Cookie manager integrated in an application program. The method comprises the following steps: receiving a request, wherein the request is any one of the following requests: a Web page request initiated from a Web page of an application program, a native page request initiated from a native page of the application program, and a native request initiated by running a native code of the application program; extracting a first domain name and a first Cookie corresponding to the first domain name from the request; if a second Cookie corresponding to the first domain name is found in the local Cookie file, a third Cookie is generated based on the first Cookie and the second Cookie, and the second Cookie is the latest Cookie corresponding to the first domain name before the request is received; and after the first Cookie in the request is replaced by the third Cookie, forwarding the request to a server specified by the first domain name, and updating the Cookie corresponding to the first domain name into the third Cookie in the local Cookie file. The connection inertia between pages can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to Cookie management methods, devices, equipment and media. Background Art

[0002] At present, in the process of developing, testing and using some applications (Application, APP), it is often necessary to jump back and forth between multiple different pages. The current problem is that the inertia between some different pages is not good enough, and the user experience is low. For example, when jumping back to the previous page from the latter page, the previous page may have a cookie expiration problem. In this case, you need to log in again on the former page. For another example, after filling in some information on the former page, this information cannot be synchronized to the latter page. Summary of the invention

[0003] In view of this, the present disclosure provides a Cookie management method, a Cookie management device, an electronic device and a computer-readable storage medium, which can improve the connectivity between different pages.

[0004] In a first aspect, the present disclosure provides a cookie management method, which is applied to a cookie manager integrated in an application; the method comprises:

[0005] Receive a request, where the request is any one of the following requests: a web page request initiated from a web page of the application, a native page request initiated from a native page of the application, or a native request initiated by running a native code of the application;

[0006] Extracting a first domain name and a first cookie corresponding to the first domain name from the request;

[0007] If the second cookie corresponding to the first domain name is found in the local cookie file, a third cookie is generated based on the first cookie and the second cookie, where the second cookie is the latest cookie corresponding to the first domain name before the request is received;

[0008] After replacing the first Cookie in the request with the third Cookie, forwarding the request to the server specified by the first domain name, and updating the Cookie corresponding to the first domain name with the third Cookie in the local Cookie file.

[0009] In a second aspect, the present disclosure provides a Cookie management device, the device comprising:

[0010] A request receiving module, used to receive a request, wherein the request is any of the following requests: a web page request initiated from a web page of the application, a native page request initiated from a native page of the application, and a native request initiated by running a native code of the application;

[0011] An information extraction module, configured to extract a first domain name and a first cookie corresponding to the first domain name from the request;

[0012] A cookie generation module, configured to generate a third cookie based on the first cookie and the second cookie if a second cookie corresponding to the first domain name is found in a local cookie file, where the second cookie is the latest cookie corresponding to the first domain name before the request is received;

[0013] A cookie update module is used to replace the first cookie in the request with the third cookie, forward the request to the server specified by the first domain name, and update the cookie corresponding to the first domain name with the third cookie in the local cookie file.

[0014] In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above method by executing the computer instructions.

[0015] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the above method.

[0016] In the technical solutions of some embodiments of the present disclosure, the Cookie manager can be equivalent to an interceptor. When the browser in the application sends a request to the server or receives a request response returned by the server, the Cookie manager can intercept the request or request response, and integrate and merge the Cookie extracted from the request or request response with the Cookie in the local Cookie file according to the domain name, and then replace the latest Cookie obtained with the request or request response. In this way, when there are native pages and Web pages that manage Cookies separately, the Cookie corresponding to the native page can include the Cookie information corresponding to the Web page, and the Cookie corresponding to the Web page can include the Cookie information corresponding to the native page. In addition, the problem of inconsistency between different pages is avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 This is a schematic diagram of the relationship between the Cookie manager and the application provided by an embodiment of the present disclosure;

[0019] Figure 2 It is a flowchart of a Cookie management method provided by an embodiment of the present disclosure;

[0020] Figure 3 is a module diagram of a Cookie manager provided by an embodiment of the present disclosure;

[0021] Figure 4 It is a schematic diagram of component interaction of a Cookie management method provided by an embodiment of the present disclosure;

[0022] Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0024] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0025] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "some embodiments" or "the embodiment" should be understood as "at least some embodiments". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.

[0026] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.

[0027] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0028] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.

[0029] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.

[0030] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.

[0031] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0032] Cookies are small text files sent by the server to the browser to help identify users and provide personalized services to users. For example, cookies can record the user's login information. Within a specified time after the user logs in to a website, if the user logs in to the website again, the browser can send cookies to the server, and the server will authenticate the user based on the cookies. In this way, when the user logs in to the website again, there is no need to enter the username, password and other information again, which simplifies the user operation. For another example, cookies can record the user's preferences on the website. When the user logs in to the website again, the server can display the page according to the user's preferences based on the information in the cookies. For another example, cookies can be used to record the products selected by the user on the shopping page. After the user jumps from the shopping page to the checkout page, the server can display the products selected by the user on the shopping page on the checkout page based on the products recorded in the cookies.

[0033] At present, the inertia problem between different pages of some apps is mainly caused by the inconsistency of cookies between pages. The following is a detailed analysis of the reasons for this inconsistency.

[0034] Specifically, the APP has a built-in browser, and the APP may include native code, native pages, and web pages. Among them, native code refers to code that runs directly on the operating system and is optimized and compiled for a specific platform or processor. In APP development, native code is usually developed based on platform-specific programming languages ​​and tools. For example, the programming language of the Android platform is Java or Kotlin, and the programming language of the iOS platform is Swift or Objective-C. Native code has high execution efficiency, can make full use of hardware resources, and provide a smoother user experience. Native pages are user interface pages developed using native code. These pages run directly on the operating system and have high performance and flexibility. Web pages are user interface pages developed using Web technologies such as HTML, CSS, and JavaScript. These pages usually run in a browser environment and have the characteristics of cross-platform compatibility, easy update, low development cost, and rapid iteration and update.

[0035] Due to different business needs, an APP can include native code, native pages, and web pages at the same time. For example, the login page is a native page, and the product display page and checkout page are web pages. Usually, during the running of the native code, it can trigger the update of cookies. User operations in native pages and web pages can also trigger the update of cookies.

[0036] In some current technologies, cookies for native pages and web pages are managed separately, which will cause inconsistency between different pages of the APP. For example, assuming that page A is a native page for displaying electrical appliances, and page B is a web page for displaying consumer products, when the cookies of page A and page B are managed separately, after the user selects product 1 on page A, the browser will return product 1 and the locally saved Cookie 1 corresponding to page A to the server. The server will add the information of product 1 to Cookie 1 based on product 1, and then return the updated Cookie 1 to the browser as the new Cookie 1 corresponding to page A. Similarly, after the user selects product 2 on page B, the browser will return product 2 and the locally saved Cookie 2 corresponding to page B to the server. The server will add the information of product 2 to Cookie 2 based on product 2, and then return the updated Cookie 2 to the browser as the new Cookie 2 corresponding to page B. In the above context, assume that the jump order between page A, page B and settlement page is page A>page B>settlement page. Then, when jumping from page B to the settlement page, the browser will send Cookie 2 corresponding to page B to the server. Based on Cookie 2, the server can determine that the user has selected Product 2, so it can return the product information of Product 2 to the browser and display it on the checkout page. As can be seen here, Product 1 selected by the user on Page A is not displayed on the checkout page (because Cookie 1 is not sent to the server). This causes the problem of inconsistency between different pages.

[0037] In view of this, the present disclosure provides a Cookie management method that can solve the above problems. Figure 1 The cookie management method can be applied to a cookie manager integrated in an application. The cookie manager can be a software product, such as a plug-in. Figure 1 , combined with reference Figure 2 , which is a flow chart of a Cookie management method provided by an embodiment of the present disclosure. Figure 2 In the present invention, the Cookie management method may include the following steps:

[0038] Step S201, receiving a request, where the request is any of the following requests: a web page request initiated from a web page of an application, a native page request initiated from a native page of an application, and a native request initiated by running a native code of an application.

[0039] Specifically, native page requests and web page requests may be generated when a user performs an operation on the user page of an application. For example, assume that the application includes a product display page, and the product display page is a native page. Then, after the user selects a product on the product display page of the application and clicks submit, a native page request may be generated, and the native page request may include the product selected by the user and the cookie corresponding to the product display page. The relevant principles are as described above and will not be repeated here.

[0040] A native request may be a request generated when the native code of an application is running in the background.

[0041] The request may include a URL address and a first cookie. The URL includes a first domain name. The first domain name is used to identify the server to which the request is to be sent. The first cookie is a cookie corresponding to the page or native code operated by the user.

[0042] Step S202: extract the first domain name and the first Cookie corresponding to the first domain name from the request.

[0043] Typically, the first domain name and the first cookie may be stored in a specified field of the request. Therefore, by parsing the request and extracting the value in the specified field, the first domain name and the first cookie corresponding to the first domain name may be obtained.

[0044] Step S203: If the second cookie corresponding to the first domain name is found in the local cookie file, a third cookie is generated based on the first cookie and the second cookie, where the second cookie is the latest cookie corresponding to the first domain name before the request is received.

[0045] Specifically, the local cookie file can be saved in the non-volatile storage of the platform. When generating the third cookie based on the first cookie and the second cookie, the first cookie and the second cookie can be compared for differences, and the first cookie and the second cookie can be merged and integrated according to the difference comparison results to obtain the third cookie. The merging and integration includes but is not limited to merging the contents of the first cookie and the second cookie, taking the latest data in chronological order, etc. The logic of merging and integration can be specified according to actual needs, and there is no restriction on this publicly. For example, assuming that the first cookie includes information about commodity A but does not include information about commodity B, and the second cookie includes information about commodity B but does not include information about commodity A, then the information about commodity A and commodity B can be merged to obtain a third cookie including information about commodities A and B. For another example, assuming that the first cookie includes information about person M at 12 noon, and the second cookie includes information about person M at 10 am, since 12 noon is closer to the current time than 10 am, the information about person M at 12 noon can be written into the third cookie, and the information about person M at 10 am can be discarded.

[0046] In summary, in this embodiment, generating a third cookie based on the first cookie and the second cookie may include:

[0047] If the first cookie and the second cookie have the same value, field and path, the first cookie is used as the third cookie; and / or

[0048] If the second cookie includes the first target field that the first cookie does not have, then the first target field and the value of the first target field are added to the first cookie to obtain a third cookie;

[0049] Specifically, when the first Cookie and the second Cookie have the same value, field and path, it means that the first Cookie and the second Cookie are roughly the same. In this case, considering that the time of the first Cookie is closer to the current time (that is, the first Cookie is newer), the first Cookie can be directly used as the third Cookie. That is, when there is a difference between the first Cookie and the second Cookie, the information in the latest Cookie (that is, the first Cookie) shall prevail.

[0050] When the second cookie includes the first target field that the first cookie does not have, the cookies can be merged and the first target field and the value of the first target field can be added to the first cookie. In this way, when there are native pages and web pages that manage cookies separately, the cookie information in the two pages can be integrated to prevent the problem of page discontinuity due to missing information.

[0051] Step S204: After replacing the first Cookie in the request with the third Cookie, the request is forwarded to the server specified by the first domain name, and in the local Cookie file, the Cookie corresponding to the first domain name is updated to the third Cookie.

[0052] Simply put, in the technical solutions of some embodiments of the present disclosure, the Cookie manager can be equivalent to an interceptor. When the browser in the application sends a request to the server or receives a request response returned by the server, the Cookie manager can intercept the request or request response, and according to the domain name, the Cookie extracted from the request or request response is integrated and merged with the Cookie in the local Cookie file, and then the latest Cookie is replaced with the request or request response. In this way, when there are native pages and Web pages that manage Cookies separately, the Cookie corresponding to the native page can include the Cookie information corresponding to the Web page, and the Cookie corresponding to the Web page can include the Cookie information corresponding to the native page. In addition, the problem of inconsistency between different pages is avoided.

[0053] Based on the above description, in some embodiments, after forwarding the request, the method of the present disclosure further includes:

[0054] Receive a request response returned by the server, and extract a fourth cookie corresponding to the first domain name from the request response;

[0055] Based on the third cookie and the fourth cookie, generate a fifth cookie;

[0056] Replace the fourth cookie in the request response with the fifth cookie, and in the local cookie file, update the cookie corresponding to the first domain name to the fifth cookie.

[0057] Specifically, when generating the fifth cookie based on the third cookie and the fourth cookie, if the third cookie and the fourth cookie have the same value, field and path, the fourth cookie is used as the fifth cookie; if the third cookie includes a second target field that the fourth cookie does not have, the second target field and the value of the second target field are added to the fourth cookie to obtain the fifth cookie. The relevant principles are as described in step S203 and are not repeated here.

[0058] In some embodiments, if the second cookie corresponding to the first domain name is not found in the local cookie file, it may mean that the cookie manager has not intercepted the request for the first domain name, that is, the request currently received is the first request for the first domain name. Therefore, there is no need to perform cookie comparison, and the request including the first cookie can be directly forwarded, and the correspondence between the first domain name and the first cookie can be written into the local cookie file.

[0059] For ease of understanding, the present application scheme is described below by way of example. For example, assume that page A is a native page for displaying electrical appliances, and page B is a web page for displaying consumer goods. When the user first selects product 1 on page A, the browser of the application will send a first request to the server based on the first domain name of the server, and carry the information of product 1 and the cookie corresponding to page A in the first request. At this time, since the Cookie Manager has not yet received a request for the first domain name (i.e., there is no cookie corresponding to the first domain name in the local Cookie file), the corresponding relationship between the first domain name and the Cookie of page A can be established in the local Cookie file, and the first request can be forwarded to the server. After the server receives the first request, it can add the information of product 1 to the Cookie of page A, obtain a new Cookie of page A, and return the first response including the new Cookie to the browser of the application. At this time, the Cookie Manager can continue to intercept the response returned by the server, and integrate the new Cookie returned by the server with the Cookie corresponding to the first domain name in the local Cookie file, and replace the Cookie in the first response with the integrated Cookie. In this way, the Cookie corresponding to the first domain name in the local Cookie file will be updated, and the information of product 1 will be added. At the same time, the Cookie corresponding to page A returned to the browser is also the integrated Cookie. When the user selects product 2 on page B first, the browser of the application will send a second request to the server based on the first domain name of the server, and carry the information of product 2 and the cookie corresponding to page B in the second request. After the Cookie Manager integrates the cookie corresponding to page B with the cookie file corresponding to the first domain name in the local Cookie file, the cookie corresponding to the first domain name in the local Cookie file will include the cookie information corresponding to pages A and B. After replacing the cookie corresponding to page A in the second request with the integrated cookie, the Cookie Manager can forward the second request to the server. Based on the information of product 2, the server can add the information of product 2 to the received cookie and return a second response including the new cookie to the application. At this time, the Cookie Manager can continue to intercept the second response returned by the server, and integrate the new cookie returned by the server with the cookie corresponding to the first domain name in the local Cookie file, and replace the cookie in the second response with the integrated cookie. In this way, the cookie corresponding to the first domain name in the local Cookie file will be updated, and the information of product 2 will be added. At the same time, the cookie corresponding to page B returned to the browser is also an integrated cookie.In this way, the cookie of page B integrates the cookie information of page A. When it is necessary to jump from page B to the checkout page, the products selected by the user on page A and page B are displayed at the same time, which improves the continuity between different pages.

[0060] In some embodiments, the method of the present disclosure further comprises:

[0061] When the application displays the preload page, obtain the second domain name from the preload page;

[0062] If the sixth cookie corresponding to the second domain name is found in the local cookie file according to the second domain name, the preloaded page is updated according to the sixth cookie.

[0063] Specifically, the preloaded page can be a page that has been pre-obtained from the server. In the preload scenario, there is no need to send a request to the server or receive a response from the server, so it is only necessary to compare and integrate the Cookie corresponding to the second domain name in the preloaded page with the Cookie corresponding to the second domain name in the local Cookie file.

[0064] In some embodiments, after displaying the preloaded page, the method of the present disclosure further includes:

[0065] In response to the preloaded page being closed, the seventh cookie is extracted from the preloaded page, and in the local cookie file, the cookie corresponding to the second domain name is updated to the seventh cookie.

[0066] In this way, it is ensured that the cookie corresponding to the second domain name in the local cookie file is the latest cookie.

[0067] Furthermore, in some technologies, in addition to the need to manage cookies by native pages, native codes, and web pages, they also need to be divided by platform. For example, the iOS platform and the Android platform need to develop a set of codes respectively to manage cookies for the iOS platform and the Android platform respectively. In this way, cookie management is divided into iOS platform + native pages and native codes, iOS platform + web pages, Android platform + native pages and native codes, and Android platform + web pages. It can be understood that when managing cookies, the amount of code development is very large. In view of this, the present disclosure proposes another solution, that is, the Cookie Manager in the present disclosure can be developed based on the Flutter framework. The Flutter framework allows developers to use a set of code libraries to build applications for multiple platforms such as Android, iOS, Web, Windows, macOS, and Linux. Therefore, when developing the Cookie Manager of the present disclosure based on the Flutter framework, there is no need to write code separately for each platform, which can significantly reduce development costs and time. In addition,

[0068] Specifically, the Flutter framework may include channels. Based on the channels, the Cookie Manager may communicate with the native code or native page of the operating system and the application to call the operating system function or the native code function of the application, or for the operating system function or the native code of the application to call.

[0069] Based on the above description, the Cookie Manager may include a first channel; the above updating or writing Cookie in the local Cookie file may include:

[0070] Through the first channel, the file operation interface of the operating system is called to update or write Cookie in the local Cookie file.

[0071] It is more efficient to update the local cookie file by calling the file operation interface of the operating system.

[0072] Furthermore, the Cookie Manager includes a second channel and an encapsulation interface for receiving a request; the receiving request may include:

[0073] In response to the encapsulation interface being called by native code in the application through the second channel, determining that a native request is received;

[0074] In response to the encapsulation interface being called by the native page in the application through the second channel, it is determined that a native page request is received.

[0075] In this way, a communication path between native code, native code and native page is established, so that native requests and native page requests can be received.

[0076] Combined with reference Figure 3 , which is a module diagram of a Cookie manager provided for an embodiment of the present disclosure. Figure 3 The Cookie Manager includes:

[0077] The Web manager is used to receive Web page requests initiated from the Web page of the application;

[0078] The application manager is used to receive native page requests initiated from the native page of the application and native requests initiated through the native code of the application;

[0079] The web manager and the application manager are respectively used to extract the first domain name and the first cookie corresponding to the first domain name from the received request, and if the second cookie corresponding to the first domain name is found in the local cookie file, a third cookie is generated based on the first cookie and the second cookie, and after replacing the first cookie in the request with the third cookie, the request is forwarded to the server specified by the first domain name, and in the local cookie file, the cookie corresponding to the first domain name is updated to the third cookie, and the second cookie is the latest cookie corresponding to the first domain name before the request is received.

[0080] In some embodiments, the web manager and the application manager are also used to receive a request response to the request after forwarding the request, and extract the fourth cookie corresponding to the first domain name from the request response, and generate a fifth cookie based on the third cookie and the fourth cookie, and in the request response, the fifth cookie will be used to replace the fourth cookie, and in the local cookie file, the cookie corresponding to the first domain name will be updated to the fifth cookie.

[0081] In some embodiments, the web manager and application manager are also used to forward the request including the first cookie if the second cookie corresponding to the first domain name is not found in the local cookie file, and write the correspondence between the first domain name and the first cookie into the local cookie file.

[0082] In some embodiments, the Cookie manager also includes a first channel, and the Web manager and the application manager are specifically used to call the file operation interface provided by the operating system through the first channel to add or modify the Cookie corresponding to the first domain name in the local Cookie file.

[0083] In some embodiments, the Cookie Manager also includes a request manager and a second channel. The request manager is used to provide an encapsulation interface. The native code in the application calls the encapsulation interface through the second channel to send a request to the application manager.

[0084] In some embodiments, the cookie manager also includes a synchronization manager, which is used to obtain a second domain name from the preloading page when the application displays the preloading page, and if the sixth cookie corresponding to the second domain name is found in the local cookie file based on the second domain name, the preloading page is updated based on the sixth cookie, and in response to the preloading page being closed, the seventh cookie is extracted from the preloading page, and the cookie corresponding to the second domain name is updated to the seventh cookie in the local cookie file.

[0085] Combined with reference Figure 4 , which is a schematic diagram of the component interaction of a Cookie management method provided by an embodiment of the present disclosure. Figure 4 The steps include:

[0086] Step S41, the application browser sends a request to the Cookie manager.

[0087] Step S42, the Cookie manager extracts the first domain name and the first Cookie corresponding to the first domain name from the request;

[0088] Step S43: The Cookie manager reads a second Cookie corresponding to the first domain name from the local Cookie file.

[0089] Step S44, the Cookie Manager compares and integrates the first Cookie and the second Cookie to obtain a third Cookie;

[0090] Step S45, the Cookie manager updates the Cookie corresponding to the first domain name in the local Cooke file based on the comparison result;

[0091] Step S46: The Cookie Manager replaces the first Cookie in the request with the third Cookie.

[0092] Combined with reference Figure 5 , which is a module diagram of a Cookie management device provided in one embodiment of the present disclosure. Figure 5 Among them, Cookie management devices include:

[0093] The request receiving module 501 is used to receive a request, where the request is any of the following requests: a web page request initiated from a web page of an application, a native page request initiated from a native page of an application, or a native request initiated by running a native code of an application;

[0094] An information extraction module 502 is used to extract the first domain name and the first cookie corresponding to the first domain name from the request;

[0095] The cookie generation module 503 is used to generate a third cookie based on the first cookie and the second cookie if the second cookie corresponding to the first domain name is found in the local cookie file, where the second cookie is the latest cookie corresponding to the first domain name before the request is received;

[0096] The cookie update module 504 is used to replace the first cookie in the request with the third cookie, forward the request to the server specified by the first domain name, and update the cookie corresponding to the first domain name with the third cookie in the local cookie file.

[0097] In some embodiments, after forwarding the request, the Cookie update module 504 is further configured to:

[0098] Receive a request response returned by the server, and extract a fourth cookie corresponding to the first domain name from the request response;

[0099] Based on the third cookie and the fourth cookie, generate a fifth cookie;

[0100] Replace the fourth cookie in the request response with the fifth cookie, and in the local cookie file, update the cookie corresponding to the first domain name to the fifth cookie.

[0101] In some embodiments, the Cookie generation module 503 is specifically used to:

[0102] If the first cookie and the second cookie have the same value, field and path, the first cookie is used as the third cookie; and / or

[0103] If the second cookie includes the first target field that the first cookie does not have, then the first target field and the value of the first target field are added to the first cookie to obtain a third cookie;

[0104] and, if the third cookie and the fourth cookie have the same value, field and path, the fourth cookie will be used as the fifth cookie; and / or

[0105] If the third cookie includes a second target field that the fourth cookie does not have, the second target field and the value of the second target field are added to the fourth cookie to obtain the fifth cookie.

[0106] In some embodiments, the Cookie update module 504 is further configured to:

[0107] If the second cookie corresponding to the first domain name is not found in the local cookie file, the request including the first cookie is forwarded, and the corresponding relationship between the first domain name and the first cookie is written into the local cookie file.

[0108] In some embodiments, the Cookie generation module 503 is further used to:

[0109] When the application displays the preload page, obtain the second domain name from the preload page;

[0110] If the sixth cookie corresponding to the second domain name is found in the local cookie file according to the second domain name, the preloaded page is updated according to the sixth cookie.

[0111] In some embodiments, after displaying the preloaded page, the Cookie generation module 503 is further used to:

[0112] In response to the preloaded page being closed, the seventh cookie is extracted from the preloaded page, and in the local cookie file, the cookie corresponding to the second domain name is updated to the seventh cookie.

[0113] In some embodiments, the Cookie Manager is developed based on the Flutter framework;

[0114] The Cookie Manager includes a first channel; the Cookie update module 504 is specifically used to:

[0115] Calling the file operation interface of the operating system through the first channel to update or write Cookie in the local Cookie file; and / or

[0116] The Cookie Manager includes a second channel and an encapsulation interface for receiving requests; the request receiving module 501 is specifically used for:

[0117] In response to the encapsulation interface being called by native code in the application through the second channel, determining that a native request is received;

[0118] In response to the encapsulation interface being called by the native page in the application through the second channel, it is determined that a native page request is received.

[0119] The cookie management device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.

[0120] The Cookie management device disclosed in the present invention has the same beneficial effects as the above-mentioned Cookie management method, which will not be repeated here.

[0121] The present disclosure also provides an electronic device having the above Figure 4 Cookie management device shown.

[0122] Combined with reference Figure 5 , is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. Figure 4 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.

[0123] The processor 10 may be a first PCIe device, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0124] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0125] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0126] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0127] The electronic device further comprises a communication interface 30 for the electronic device to communicate with other devices or a communication network.

[0128] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0129] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0130] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A Cookie management method, characterized in that: Applicable to a Cookie manager integrated in an application; the method comprises: Receive a request, where the request is any one of the following requests: a web page request initiated from a web page of the application, a native page request initiated from a native page of the application, or a native request initiated by running a native code of the application; Extracting a first domain name and a first cookie corresponding to the first domain name from the request; If the second cookie corresponding to the first domain name is found in the local cookie file, a third cookie is generated based on the first cookie and the second cookie, where the second cookie is the latest cookie corresponding to the first domain name before the request is received; After replacing the first Cookie in the request with the third Cookie, forwarding the request to the server specified by the first domain name, and updating the Cookie corresponding to the first domain name with the third Cookie in the local Cookie file.

2. The method according to claim 1, characterized in that After forwarding the request, the method further includes: Receive a request response returned by the server, and extract a fourth cookie corresponding to the first domain name from the request response; Generate a fifth cookie based on the third cookie and the fourth cookie; The fourth cookie in the request response is replaced with the fifth cookie, and in the local cookie file, the cookie corresponding to the first domain name is updated with the fifth cookie.

3. The method according to claim 2, characterized in that The generating a third cookie based on the first cookie and the second cookie includes: If the first Cookie and the second Cookie have the same value, field and path, the first Cookie is used as the third Cookie; and / or If the second Cookie includes a first target field that the first Cookie does not have, then the first target field and the value of the first target field are added to the first Cookie to obtain the third Cookie; And, based on the third cookie and the fourth cookie, generating a fifth cookie, including: If the third cookie and the fourth cookie have the same value, field and path, the fourth cookie is used as the fifth cookie; and / or If the third Cookie includes a second target field that the fourth Cookie does not have, the second target field and the value of the second target field are added to the fourth Cookie to obtain the fifth Cookie.

4. The method according to claim 1, characterized in that: The method further comprises: If the second cookie corresponding to the first domain name is not found in the local cookie file, the request including the first cookie is forwarded, and the correspondence between the first domain name and the first cookie is written into the local cookie file.

5. The method according to claim 1, characterized in that The method further comprises: When the application displays the preload page, obtaining a second domain name from the preload page; If the sixth cookie corresponding to the second domain name is found in the local cookie file according to the second domain name, the preloaded page is updated according to the sixth cookie.

6. The method according to claim 5, characterized in that After displaying the preloaded page, the method further includes: In response to the preloaded page being closed, extracting the seventh cookie from the preloaded page, and updating the cookie corresponding to the second domain name to the seventh cookie in the local cookie file.

7. The method according to any one of claims 1 to 5, characterized in that: The Cookie Manager is developed based on the Flutter framework; The Cookie manager includes a first channel; updating or writing Cookie in the local Cookie file includes: Calling the file operation interface of the operating system through the first channel to update or write Cookie in the local Cookie file; and / or The Cookie Manager includes a second channel and an encapsulation interface for receiving a request; the receiving request includes: In response to the encapsulation interface being called by the native code in the application through the second channel, determining that the native request is received; In response to the encapsulation interface being called by the native page in the application through the second channel, it is determined that the native page request is received.

8. A Cookie management device, characterized in that: The device comprises: A request receiving module, used to receive a request, wherein the request is any of the following requests: a web page request initiated from a web page of an application, a native page request initiated from a native page of the application, and a native request initiated by running a native code of the application; An information extraction module, configured to extract a first domain name and a first cookie corresponding to the first domain name from the request; A cookie generation module, configured to generate a third cookie based on the first cookie and the second cookie if a second cookie corresponding to the first domain name is found in a local cookie file, where the second cookie is the latest cookie corresponding to the first domain name before the request is received; A cookie update module is used to replace the first cookie in the request with the third cookie, forward the request to the server specified by the first domain name, and update the cookie corresponding to the first domain name with the third cookie in the local cookie file.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the Cookie management method according to any one of claims 1 to 7 by executing the computer instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the Cookie management method according to any one of claims 1 to 7.