CN108388657B - Cookie storage method, device, equipment and readable storage medium - Google Patents

Cookie storage method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN108388657B
CN108388657B CN201810184325.8A CN201810184325A CN108388657B CN 108388657 B CN108388657 B CN 108388657B CN 201810184325 A CN201810184325 A CN 201810184325A CN 108388657 B CN108388657 B CN 108388657B
Authority
CN
China
Prior art keywords
cookie
stored
domain name
cookies
domain
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
CN201810184325.8A
Other languages
Chinese (zh)
Other versions
CN108388657A (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.)
Wuba Co Ltd
Original Assignee
Wuba 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 Wuba Co Ltd filed Critical Wuba Co Ltd
Priority to CN201810184325.8A priority Critical patent/CN108388657B/en
Publication of CN108388657A publication Critical patent/CN108388657A/en
Application granted granted Critical
Publication of CN108388657B publication Critical patent/CN108388657B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Abstract

The invention discloses a cookie storage method, a cookie storage device, cookie storage equipment and a readable storage medium, wherein the cookie storage method comprises the following steps: obtaining a cookie to be stored; determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie; setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored; and replacing the target cookie by the cookie to be stored after the domain name setting. The cookie storage mode avoids the problem of cookie loss caused by the limitation of cookie storage number, and the cookie does not need to be spliced, so that the use efficiency of the cookie is prevented from being influenced.

Description

Cookie storage method, device, equipment and readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a cookie storage method, device, and apparatus, and a readable storage medium.
Background
Currently, web pages are widely used in application programs, and cookies are a very common technology in web technology.
In an Android device, a web page carrier WebView provides good package for the use of cookies, but due to the complexity of services, various scenes which do not meet service requirements are often encountered in the use process. For example, in the underlying implementation of WebView, the following restrictions are made on the storable number of cookies: the maximum cookie amount is stored under each domain name, and after the limit is exceeded, the cookie amount is deleted every time; all domain names store up to many cookies, and after the limit is exceeded, many cookies are deleted each time.
This leads to a problem: if the number of the domain names stored under one domain name exceeds the limit, the domain names can be deleted by WebView according to the rule of the WebView, so that the domain names cannot be acquired when the cookie needs to be used next time.
In the prior art, the more popular solutions are: the method comprises the steps that a plurality of cookies under the same domain name are combined into one cookie in a preset format, the cookie is acquired every time when a service party uses the cookie, specifically which data in the cookie is needed, and the service party is required to analyze the cookie for acquisition. However, the above-described method has the following disadvantages: 1) when cookie is stored each time, new cookie data needs to be spliced on the basis of the cookie data stored; 2) and when the service party acquires the cookie for use, the service party needs to analyze the cookie once by self to obtain the data really needed. It can be seen that the storage scheme of "merging multiple cookies under the same domain name into one cookie in a predetermined format" is achieved at the cost of sacrificing the efficiency of cookie usage.
Therefore, how to store the cookie becomes a technical problem to be solved by the embodiment of the present invention, which can solve the problem of cookie loss caused by the limitation of cookie storage number in the prior art, and can also avoid influencing the cookie use efficiency.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are provided to provide a cookie storage method, apparatus, device and readable storage medium that solve the above problems.
According to a first aspect of embodiments of the present invention, there is provided a cookie storage method, including:
obtaining a cookie to be stored;
determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie;
setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored;
and replacing the target cookie by the cookie to be stored after the domain name setting.
Optionally, after obtaining the cookie to be stored, the method further includes:
judging whether the number of the stored cookies reaches a set threshold value, if so, executing the operation of determining the target cookies; otherwise, the cookie to be stored is directly stored.
Optionally, determining a target cookie having a common domain name with a domain name in cookies to be stored specifically includes:
determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies;
and selecting a cookie with the domain name containing the largest common action domain with the domain name in the cookies to be stored from the plurality of determined cookies as a determined target cookie.
Optionally, selecting a domain name and a cookie with a domain name having a largest common domain in cookies to be stored includes:
and selecting a cookie with the domain name having the largest common string with the domain name in the cookies to be stored.
Optionally, when replacing the target cookie with the cookie to be stored after the domain name setting, the method further includes:
and setting the host index corresponding to the replaced cookie as a domain name coaction domain of the target cookie and the cookie to be stored.
According to a second aspect of embodiments of the present invention, there is provided a cookie storage apparatus, the apparatus including:
the cookie to be stored acquiring module is used for acquiring cookies to be stored;
the target cookie acquiring module is used for determining a target cookie of which the domain name and the domain name in the cookie to be stored have a common action domain in the stored cookies;
the setting module is used for setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored;
and the replacing module is used for replacing the target cookie by using the cookie to be stored after the domain name setting.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the number of the stored cookies reaches a set threshold value, and if yes, executing the operation of determining the target cookies; otherwise, the cookie to be stored is directly stored.
Optionally, the target cookie obtaining module includes:
the target cookie inquiry unit is used for determining a plurality of cookies of which the domain name and the domain name of the cookie to be stored have a common action domain in the stored cookies;
and the target cookie confirming unit is used for selecting a cookie with the domain name containing the largest common action domain with the domain name in the cookies to be stored from the plurality of determined cookies as the determined target cookie.
Optionally, the target cookie confirmation unit is specifically configured to select, from the determined multiple cookies, a cookie having a domain name with a largest common string with a domain name in cookies to be stored as the determined target cookie.
Optionally, the apparatus further comprises:
and the host index module is used for setting the host index corresponding to the replaced cookie as a domain name coaction domain of the target cookie and the cookie to be stored.
According to a third aspect of embodiments of the present invention, there is provided a computing device comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the cookie storage program stored in the memory to realize the steps of the cookie storage method provided by the embodiment of the invention.
According to a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a cookie storage program is stored, and when the cookie storage program is executed by at least one processor, the steps of the cookie storage method provided by the embodiments of the present invention are implemented.
According to the cookie storage method, the cookie storage device, the cookie storage equipment and the readable storage medium, provided by the embodiment of the invention, the cookie to be stored is obtained; determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie; setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored; and replacing the target cookie by the cookie to be stored after the domain name setting. The cookie storage mode avoids the problem of cookie loss caused by the limitation of cookie storage number, and the cookie does not need to be spliced, so that the use efficiency of the cookie is prevented from being influenced.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and the embodiments of the present invention can be implemented according to the content of the description in order to make the technical means of the embodiments of the present invention more clearly understood, and the detailed description of the embodiments of the present invention is provided below in order to make the foregoing and other objects, features, and advantages of the embodiments of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the embodiments of the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart of a cookie storage method according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a cookie storage method according to a second embodiment of the present invention;
FIG. 3 is a flowchart of a cookie storage method according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a cookie storage method according to a fourth embodiment of the present invention;
fig. 5 is a flowchart of a cookie storage method according to a fifth embodiment of the present invention;
FIG. 6 is a functional block diagram of a cookie storage apparatus according to a sixth embodiment of the present invention;
FIG. 7 is a functional block diagram of a cookie storage apparatus according to a seventh embodiment of the present invention;
fig. 8 is a functional block diagram of a cookie storage apparatus according to an eighth embodiment to a ninth embodiment of the present invention;
fig. 9 is a schematic functional module diagram of a cookie storage apparatus according to a tenth embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In internet interactive technology, hypertext Transfer Protocol (HTTP) is stateless, and each HTTP request is independent of each other. The cookie (sometimes, complex cookies refer to data stored on a local terminal of a user by some websites for identifying the user identity and tracking the session) is used for storing state data of the user in the terminal, the data is sent to the server along with each http request, and the server analyzes the cookie data to know the state of the terminal.
Referring to fig. 1, a flowchart of a cookie storage method according to a first embodiment of the present invention is shown. In this embodiment, the cookie storage method includes the following steps:
step S101, obtaining the cookie to be stored.
In this embodiment, the cookie to be stored may be a cookie that the terminal receives feedback from the server, or a cookie that the terminal receives an import from another terminal. It can be clear that, when the terminal receives the cookie fed back by the server or receives cookies imported by other terminals, the cookie can be temporarily stored in the cache, so that when the cookie needs to be processed by the terminal, the corresponding cookie can be obtained from the cache.
Step S102, in the stored cookie, determining a target cookie with a domain name having a common action domain with the domain name in the cookie to be stored.
cookies generally consist of variable names and values, and the cookie format is as follows: NAME ═ VALUE; expires ═ DATE; path ═ Path; domain _ NAME; SECURE
And confirming a target cookie having a common action Domain with the Domain corresponding to the cookie to be stored in the stored cookies according to the Domain corresponding to the acquired cookie to be stored. And if the Domain corresponding to the cookie to be stored is aa.bb.com, confirming that one Domain contains the cookie xx.aa.bb.com, aa.bb.com or bb.com in the stored cookies as the target cookie.
And step S103, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
In this embodiment, a common scope is obtained according to the Domain of the confirmed target cookie and the cookie to be stored, and the Domain name in the cookie to be stored is set as the obtained common scope. If so, the Domain corresponding to the cookie to be stored is aa.bb.com; confirming a target cookie in the stored cookies, wherein Domain of the target cookie is bb.bb.com; com, the co-scope derived from Domain of the target cookie and the cookie to be stored is bb. Domain of cookie to be stored: com is set to the resulting co-acting domain bb.com. It should be noted that when the Domain corresponding to the cookie to be stored is xx.aa.bb.com; and when a target cookie is confirmed in the stored cookies, and the Domain of the target cookie contains yy.aa.bb.com, the common scope obtained according to the Domain of the target cookie and the Domain of the cookie to be stored is aa.bb.com or bb.com. The Domain of the cookie to be stored may be: aa.bb.com is set to the resulting co-domain aa.bb.com or bb.com.
And step S104, replacing the target cookie with the cookie to be stored after the domain name is set.
Specifically, the cookie to be stored after the domain name is set is stored, and the target cookie is deleted.
Obtaining a cookie to be stored; determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie; setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored; and replacing the target cookie by the cookie to be stored after the domain name setting. The problem of cookie loss caused by the limitation of cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 2, a flowchart of a cookie storage method according to a second embodiment of the present invention is shown. In this embodiment, the cookie storage method includes the following steps:
step S201, a cookie to be stored is acquired.
Step S202, judging whether the number of the stored cookies reaches the set threshold value.
In the embodiment of the present invention, when it is determined that the number of stored cookies reaches the set threshold, step S203 is executed; when it is determined that the number of cookies stored does not reach the set threshold value, step S206 is performed.
In step S203, in the stored cookie, a target cookie having a domain name with a common domain name in the cookie to be stored is determined.
And step S204, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
And step S205, replacing the target cookie with the cookie to be stored after the domain name is set.
And step S206, storing the cookie to be stored.
And judging whether the number of the stored cookies reaches a set threshold value, determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookies when the number of the stored cookies reaches the set threshold value, and replacing the target cookie with the cookie to be stored after the domain name is set. And when the number of the stored cookies is judged not to reach the set threshold value, the storage space of the cookies is sufficient, the domain name of the cookie to be stored does not need to be set, and the cookie to be stored is directly stored. The number of the cookies may be the total number of the stored cookies, or the total number of the stored cookies corresponding to the top-level Domain name of the Domain where the cookies are to be stored. The problem of cookie loss caused by the limitation of cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Preferably, the determining whether the number of stored cookies reaches a set threshold specifically includes: acquiring a top-level Domain name corresponding to the Domain of the cookie to be stored, confirming the number of cookies corresponding to the top-level Domain name in the stored cookie, and judging whether the number of the cookies reaches a threshold value. If yes, executing the operation of determining the target cookie; otherwise, directly storing the cookie to be stored. By acquiring the top-level Domain name corresponding to the Domain of the cookie to be stored, confirming the cookie number corresponding to the top-level Domain name in the stored cookie, and judging whether the cookie number reaches the threshold value, the Domain name corresponding to the stored cookie can be prevented from being under the same top-level Domain name, and storage spaces of cookies corresponding to different top-level Domain names are reserved, so that the cookie storage benefit is improved.
Referring to fig. 3, a flowchart of a cookie storing method according to a third embodiment of the present invention is shown. In this embodiment, the cookie storage method includes the following steps:
step S301, obtaining the cookie to be stored.
Step S302, in the stored cookies, a plurality of cookies of which the domain name and the domain name of the cookie to be stored have a common action domain are determined.
In this embodiment, a plurality of cookies having a common action domain with the domain name corresponding to the cookie to be stored are determined in the stored cookie through the obtained domain name corresponding to the cookie to be stored. The number of the acquired cookies having the common action domain with the cookie domain name to be stored can be unique or multiple.
Step S303, selecting a cookie with the domain name containing the maximum coaction domain from the plurality of determined cookies as a determined target cookie, wherein the domain name and the domain name in the cookie to be stored contain the maximum coaction domain.
In this embodiment, in the determined cookies, a cookie having a domain name containing a largest co-action domain with a domain name in the cookies to be stored is selected as the determined target cookie. For example, when two cookies are determined, the Domain of one cookie is xx.aa.bb.com, and the Domain of the other target cookie is bb.com; and determining the cookie corresponding to the aa.bb.com as the target cookie in the determined 2 cookies.
And step S304, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
Step S305, the cookie to be stored after the domain name setting is used for replacing the target cookie.
Determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies; selecting a domain name from the plurality of determined cookies and a cookie with the largest common action domain in the domain name to be stored as a determined target cookie; and setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored, so that cookie information of different users can be stored as much as possible when different users log in the same domain name. And replacing the target cookie by the cookie to be stored after the domain name setting. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 4, a flowchart of a cookie storing method according to a fourth embodiment of the present invention is shown. In this embodiment, the cookie storage method includes the following steps:
step S401, obtaining the cookie to be stored.
Step S402, in the stored cookies, determining a plurality of cookies of which the domain name and the domain name of the cookie to be stored have a common action domain.
Step S403, selecting a cookie with the domain name having the largest common string with the domain name in the cookies to be stored from the plurality of determined cookies as a determined target cookie.
In this embodiment, in the determined cookies, a cookie having a domain name containing the largest common string with the domain name in the cookie to be stored is selected, so that the cookie to be stored can be quickly matched to the corresponding target cookie.
Step S404, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
Step S405, the cookie to be stored after the domain name setting is used for replacing the target cookie.
Determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies; selecting a domain name and a cookie with the largest public string in the domain names in the cookies to be stored from the plurality of determined cookies as a determined target cookie; and setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored. When different users log in the same domain name, cookie information of the users is stored as much as possible. And replacing the target cookie by the cookie to be stored after the domain name setting. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 5, a flowchart of a cookie storing method according to a fifth embodiment of the present invention is shown. In this embodiment, the cookie storage method includes the following steps:
step S501, obtaining the cookie to be stored.
Step S502, in the stored cookie, a target cookie having a domain name with a common action domain with the domain name in the cookie to be stored is determined.
Step S503, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
And step S504, replacing the target cookie with the cookie to be stored after the domain name is set.
And step S505, setting the host index corresponding to the replaced cookie as a domain name coaction domain of the target cookie and the cookie to be stored.
In this embodiment, the host index corresponding to the replaced cookie is set as the domain name coaction field of the target cookie and the cookie to be stored, so that when the domain name corresponding to the coaction field is accessed next time, the IP address corresponding to the domain name is quickly acquired, the use experience of the user is improved, and meanwhile, the problem that the cookie is lost due to the limitation of the cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 6, a functional module diagram of a cookie storage apparatus 100 according to a sixth embodiment of the present invention is shown. Applied to a computer device, the cookie storage apparatus 100 includes a to-be-stored cookie retrieval module 110, a target cookie retrieval module 130, a setting module 140, and a replacement module 150. The device is mainly used for realizing the cookie storage method provided by the embodiment of the invention, and the method is mainly used for solving the problem of cookie loss caused by the limitation of cookie storage number in the prior art.
Including but not limited to mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices.
A to-be-stored cookie obtaining module 110, configured to obtain a cookie to be stored.
In this embodiment, the cookie to be stored may be a cookie that the terminal receives feedback from the server, or a cookie that the terminal receives an import from another terminal. It can be clear that, when the terminal receives the cookie fed back by the server or receives cookies imported by other terminals, the cookie can be temporarily stored in the cache, so that when the cookie needs to be processed by the terminal, the corresponding cookie can be obtained from the cache.
And a target cookie acquiring module 130, configured to determine, in the stored cookies, a target cookie having a domain name with a common action domain with a domain name in the cookie to be stored.
cookies generally consist of variable names and values, and the cookie format is as follows: NAME ═ VALUE; expires ═ DATE; path ═ Path; domain _ NAME; SECURE
And confirming a target cookie having a common action Domain with the Domain corresponding to the cookie to be stored in the stored cookies according to the Domain corresponding to the acquired cookie to be stored. And if the Domain corresponding to the cookie to be stored is aa.bb.com, confirming that one Domain contains the cookie xx.aa.bb.com, aa.bb.com or bb.com in the stored cookies as the target cookie.
The setting module 140 is configured to set a domain name in the cookie to be stored according to the domain name co-acting domain of the target cookie and the cookie to be stored.
In this embodiment, a common scope is obtained according to the Domain of the confirmed target cookie and the cookie to be stored, and the Domain name in the cookie to be stored is set as the obtained common scope. If so, the Domain corresponding to the cookie to be stored is aa.bb.com; confirming a target cookie in the stored cookies, wherein Domain of the target cookie is bb.bb.com; com, the co-scope derived from Domain of the target cookie and the cookie to be stored is bb. Domain of cookie to be stored: com is set to the resulting co-acting domain bb.com. It should be noted that when the Domain corresponding to the cookie to be stored is xx.aa.bb.com; and when a target cookie is confirmed in the stored cookies, and the Domain of the target cookie contains yy.aa.bb.com, the common scope obtained according to the Domain of the target cookie and the Domain of the cookie to be stored is aa.bb.com or bb.com. The Domain of the cookie to be stored may be: aa.bb.com is set to the resulting co-domain aa.bb.com or bb.com.
And a replacing module 150, configured to replace the target cookie with the cookie to be stored after the domain name setting.
And storing the cookie to be stored after the domain name is set, and deleting the target cookie.
Obtaining a cookie to be stored; determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie; setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored; and replacing the target cookie by the cookie to be stored after the domain name setting. The problem of cookie loss caused by the limitation of cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 7, a functional module diagram of a cookie storage apparatus 100 according to a seventh embodiment of the present invention is shown. Applications to computer devices include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices. The cookie storage apparatus 100 includes a to-be-stored cookie retrieval module 110, a target cookie retrieval module 130, a setting module 140, and a replacement module 150. On the basis of the sixth embodiment, the apparatus further includes:
a judging module 120, configured to judge whether the number of stored cookies reaches a set threshold, and if yes, execute an operation of determining a target cookie; otherwise, the cookie to be stored is directly stored.
And judging whether the number of the stored cookies reaches a set threshold value, determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookies when the number of the stored cookies reaches the set threshold value, and replacing the target cookie with the cookie to be stored after the domain name is set. And when the number of the stored cookies is judged not to reach the set threshold value, the storage space of the cookies is sufficient, the domain name of the cookie to be stored does not need to be set, and the cookie to be stored is directly stored. The number of the cookies may be the total number of the stored cookies, or the total number of the stored cookies corresponding to the top-level Domain name of the Domain where the cookies are to be stored. The problem of cookie loss caused by the limitation of cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Optionally, the determining whether the number of stored cookies reaches a set threshold specifically includes: acquiring a top-level Domain name corresponding to the Domain of the cookie to be stored, confirming the number of cookies corresponding to the top-level Domain name in the stored cookie, and judging whether the number of the cookies reaches a threshold value. If yes, executing the operation of determining the target cookie; otherwise, directly storing the cookie to be stored. By acquiring the top-level Domain name corresponding to the Domain of the cookie to be stored, confirming the cookie number corresponding to the top-level Domain name in the stored cookie, and judging whether the cookie number reaches the threshold value, the Domain name corresponding to the stored cookie can be prevented from being under the same top-level Domain name, and storage spaces of cookies corresponding to different top-level Domain names are reserved, so that the cookie storage benefit is improved.
Fig. 8 is a schematic functional module diagram of a cookie storage apparatus 100 according to an eighth embodiment of the present invention. Applications to computer devices include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices. The cookie storage apparatus 100 includes a to-be-stored cookie retrieval module 110, a target cookie retrieval module 130, a setting module 140, and a replacement module 150. On the basis of the sixth embodiment, the target cookie acquiring module 130 includes:
and a target cookie querying unit 131, configured to determine, among the stored cookies, cookies whose domain names have a common scope with the domain name of the cookie to be stored.
In this embodiment, a plurality of cookies having a common action domain with the domain name corresponding to the cookie to be stored are determined in the stored cookie through the obtained domain name corresponding to the cookie to be stored. The number of the acquired cookies having the common action domain with the cookie domain name to be stored can be unique or multiple.
And the target cookie confirmation unit 132 is configured to select, as the determined target cookie, a cookie having a domain name containing the largest co-acting domain with the domain name in the cookies to be stored, from among the determined cookies.
In this embodiment, in the determined cookies, a cookie having a domain name containing a largest co-action domain with a domain name in the cookies to be stored is selected as the determined target cookie. For example, when two cookies are determined, the Domain of one cookie is xx.aa.bb.com, and the Domain of the other target cookie is bb.com; and determining the cookie corresponding to the aa.bb.com as the target cookie in the determined 2 cookies.
Determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies; selecting a domain name from the plurality of determined cookies and a cookie with the largest common action domain in the domain name to be stored as a determined target cookie; and setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored, so that cookie information of different users can be stored as much as possible when different users log in the same domain name. And replacing the target cookie by the cookie to be stored after the domain name setting. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Fig. 8 is a schematic functional module diagram of a cookie storage apparatus 100 according to a ninth embodiment of the present invention. Applications to computer devices include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices. The cookie storage apparatus 100 includes a to-be-stored cookie retrieval module 110, a target cookie retrieval module 130, a setting module 140, and a replacement module 150. On the basis of the eighth embodiment, the target cookie confirmation unit 132 is specifically configured to select, from the determined multiple cookies, a cookie whose domain name has the largest common string with the domain name in the cookies to be stored, as the determined target cookie.
In this embodiment, in the determined cookies, a cookie having a domain name containing the largest common string with the domain name in the cookie to be stored is selected, so that the cookie to be stored can be quickly matched to the corresponding target cookie.
Determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies; selecting a domain name and a cookie with the largest public string in the domain names in the cookies to be stored from the plurality of determined cookies as a determined target cookie; and setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored. When different users log in the same domain name, cookie information of the users is stored as much as possible. And replacing the target cookie by the cookie to be stored after the domain name setting. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
Referring to fig. 9, a functional module diagram of a cookie storage apparatus 100 according to a tenth embodiment of the present invention is shown. Applications to computer devices include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices. The cookie storage apparatus 100 includes a to-be-stored cookie retrieval module 110, a target cookie retrieval module 130, a setting module 140, and a replacement module 150. On the basis of the sixth embodiment, the apparatus further includes:
and a host index module 160, configured to set a host index corresponding to the replaced cookie as a domain name coaction domain of the target cookie and the cookie to be stored.
In this embodiment, the host index corresponding to the replaced cookie is set as the domain name coaction field of the target cookie and the cookie to be stored, so that when the domain name corresponding to the coaction field is accessed next time, the IP address corresponding to the domain name is quickly acquired, the use experience of the user is improved, and meanwhile, the problem that the cookie is lost due to the limitation of the cookie storage number in the prior art is solved. Compared with the prior art (a plurality of cookies under the same domain name are combined into one cookie by a preset format): the cookie loss problem caused by the limitation of WebView on the storage number of cookies is effectively avoided; the time-consuming process that the stored cookie is acquired when the cookie is stored every time, and then the cookie is spliced and stored is omitted; time-consuming analysis operation when the service party acquires the cookie every time is omitted, and efficiency of using the cookie by the service party is improved.
An embodiment of the present invention further provides a computer device, including: a processor, a memory, and a communication bus; the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the cookie storage program of the application program stored in the memory so as to realize the following steps:
step S101, obtaining the cookie to be stored.
Step S102, in the stored cookie, determining a target cookie with a domain name having a common action domain with the domain name in the cookie to be stored.
And step S103, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
And step S104, replacing the target cookie with the cookie to be stored after the domain name is set.
Alternatively, the steps performed may be replaced with steps S201 to S206, steps S301 to S305, S401 to S405, and steps S501 to S505.
Since the cookie storage method implementation process has been described in detail in the first to fifth embodiments, details are not described in this embodiment.
The computer devices in this embodiment include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices.
Embodiments of the present invention also provide a computer-readable storage medium storing a cookie storage method, which when executed by at least one processor causes the at least one processor to perform the steps of:
step S101, obtaining the cookie to be stored.
Step S102, in the stored cookie, determining a target cookie with a domain name having a common action domain with the domain name in the cookie to be stored.
And step S103, setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored.
And step S104, replacing the target cookie with the cookie to be stored after the domain name is set.
Alternatively, the steps performed may be replaced with steps S201 to S206, steps S301 to S305, S401 to S405, and steps S501 to S505.
The computer-readable storage medium of this embodiment includes, but is not limited to: ROM, RAM, magnetic or optical disks, and the like.
Since the cookie storage method implementation process has been described in detail in the first to fifth embodiments, details are not described in this embodiment.
The computer devices in this embodiment include, but are not limited to, mobile phones, cell phones, smart phones, tablets, personal computers, personal digital assistants, media players, and other electronic devices.
In summary, the embodiment of the present invention discloses a cookie storage method, apparatus, device and readable storage medium, by acquiring a cookie to be stored; determining a target cookie with a common action domain between the domain name and the domain name in the cookie to be stored in the stored cookie; setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored; and replacing the target cookie by the cookie to be stored after the domain name setting. The cookie storage mode avoids the problem of cookie loss caused by the limitation of cookie storage number, and the cookie does not need to be spliced, so that the use efficiency of the cookie is prevented from being influenced.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In short, the above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A cookie storage method, the method comprising:
obtaining a cookie to be stored;
determining a target cookie with a domain name having a common action domain with the domain name in the cookie to be stored in the stored cookie;
setting a domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored;
and replacing the target cookie with the cookie to be stored after the domain name setting.
2. The method of claim 1, after obtaining the cookie to be stored, further comprising:
judging whether the number of the stored cookies reaches a set threshold value, if so, executing the operation of determining the target cookies; otherwise, directly storing the cookie to be stored.
3. The method according to claim 1, wherein the determining a target cookie having a domain name with a common scope with a domain name in the cookie to be stored specifically comprises:
determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have common action domains in the stored cookies;
and selecting a cookie with the domain name containing the maximum common action domain with the domain name in the cookies to be stored from the plurality of determined cookies as a determined target cookie.
4. The method of claim 3, wherein selecting a cookie having a domain name with a largest co-action domain with a domain name in the cookie to be stored comprises:
and selecting a cookie with the domain name having the largest common string with the domain name in the cookies to be stored.
5. The method according to any one of claims 1 to 4, wherein when replacing the target cookie with the cookie to be stored after the domain name setting, the method further comprises:
and setting the host index corresponding to the replaced cookie as a domain name coaction domain of the target cookie and the cookie to be stored.
6. A cookie storage apparatus, the apparatus comprising:
the cookie to be stored acquiring module is used for acquiring cookies to be stored;
the target cookie acquiring module is used for determining a target cookie of which the domain name and the domain name in the cookie to be stored have a common action domain in the stored cookies;
the setting module is used for setting the domain name in the cookie to be stored according to the domain name coaction domain of the target cookie and the cookie to be stored;
and the replacing module is used for replacing the target cookie by using the cookie to be stored after the domain name setting.
7. The apparatus of claim 6, further comprising:
the judging module is used for judging whether the number of the stored cookies reaches a set threshold value, and if yes, executing the operation of determining the target cookies; otherwise, directly storing the cookie to be stored.
8. The apparatus of claim 6, wherein the target cookie retrieval module comprises:
the target cookie inquiry unit is used for determining a plurality of cookies of which the domain names and the domain names of the cookies to be stored have a common action domain in the stored cookies;
and the target cookie confirming unit is used for selecting a cookie with the domain name containing the maximum common action domain with the domain name in the cookies to be stored from the plurality of determined cookies as the determined target cookie.
9. The apparatus according to claim 8, wherein the target cookie validation unit is specifically configured to select, as the determined target cookie, a cookie having a domain name with a largest common string with a domain name in the cookies to be stored, from among the determined cookies.
10. The apparatus of any one of claims 6 to 9, further comprising:
and the host index module is used for setting the host index corresponding to the replaced cookie as a domain name common action domain of the target cookie and the cookie to be stored.
11. A computing device, comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute a cookie storage program stored in the memory to implement the steps of the method of any of claims 1 to 5.
12. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a cookie storage program, which when executed by at least one processor implements the method steps of any of claims 1 to 5.
CN201810184325.8A 2018-03-06 2018-03-06 Cookie storage method, device, equipment and readable storage medium Active CN108388657B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810184325.8A CN108388657B (en) 2018-03-06 2018-03-06 Cookie storage method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810184325.8A CN108388657B (en) 2018-03-06 2018-03-06 Cookie storage method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN108388657A CN108388657A (en) 2018-08-10
CN108388657B true CN108388657B (en) 2022-04-05

Family

ID=63066601

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810184325.8A Active CN108388657B (en) 2018-03-06 2018-03-06 Cookie storage method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN108388657B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102638581A (en) * 2012-03-31 2012-08-15 奇智软件(北京)有限公司 Cookie information storage method and cookie information storage system
CN102800005A (en) * 2012-07-20 2012-11-28 北京亿赞普网络技术有限公司 Network advertisement putting method and device
CN103327036A (en) * 2012-03-19 2013-09-25 精硕世纪科技(北京)有限公司 Identification method of Internet browsing devices and Cookie server
CN103944942A (en) * 2013-01-22 2014-07-23 腾讯科技(深圳)有限公司 Multi-WEB environment data access method and device
CN104615597A (en) * 2013-11-04 2015-05-13 腾讯科技(深圳)有限公司 Method, device and system for clearing cache file in browser
CN104836803A (en) * 2015-04-24 2015-08-12 北京工商大学 Single sign-on method based on session mechanism
CN105808731A (en) * 2016-03-09 2016-07-27 北京小米移动软件有限公司 Data storage method and device
CN106790635A (en) * 2017-01-06 2017-05-31 聚好看科技股份有限公司 Cookie information management method and server

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104038914B (en) * 2013-03-08 2018-04-24 中兴通讯股份有限公司 A kind of method and device of Cookie error correction
US10193882B2 (en) * 2016-06-12 2019-01-29 Criteo Sa Provision of cross-device identification
CN107635027B (en) * 2017-09-27 2021-03-30 网易(杭州)网络有限公司 Domain name resolution method, medium, device and computing equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103327036A (en) * 2012-03-19 2013-09-25 精硕世纪科技(北京)有限公司 Identification method of Internet browsing devices and Cookie server
CN102638581A (en) * 2012-03-31 2012-08-15 奇智软件(北京)有限公司 Cookie information storage method and cookie information storage system
CN102800005A (en) * 2012-07-20 2012-11-28 北京亿赞普网络技术有限公司 Network advertisement putting method and device
CN103944942A (en) * 2013-01-22 2014-07-23 腾讯科技(深圳)有限公司 Multi-WEB environment data access method and device
CN104615597A (en) * 2013-11-04 2015-05-13 腾讯科技(深圳)有限公司 Method, device and system for clearing cache file in browser
CN104836803A (en) * 2015-04-24 2015-08-12 北京工商大学 Single sign-on method based on session mechanism
CN105808731A (en) * 2016-03-09 2016-07-27 北京小米移动软件有限公司 Data storage method and device
CN106790635A (en) * 2017-01-06 2017-05-31 聚好看科技股份有限公司 Cookie information management method and server

Also Published As

Publication number Publication date
CN108388657A (en) 2018-08-10

Similar Documents

Publication Publication Date Title
CN102572014B (en) Message treatment method, device and system
CN104253741B (en) A kind of method for sending information, relevant apparatus and system
CN102693297B (en) Data processing method, node and ETL (extract transform and load) system
CN103544020A (en) Method and mobile terminal for displaying application software icons
CN106534268B (en) Data sharing method and device
CN103327013A (en) Contact person information sharing method and equipment based on sharing permission level
US20170199889A1 (en) Method and device for identifying junk picture files
CN109815112B (en) Data debugging method and device based on functional test and terminal equipment
CN104702564A (en) Tethering user identification method and device
CN106549989A (en) A kind of data transmission method and its system, user terminal, application server
CN104618388A (en) Quick registration and login method and corresponding reset server and information server
CN110413846B (en) Data processing method and device for webpage mirror image and computer readable storage medium
CN111367857A (en) Data storage method and device, FTP server and storage medium
CN103684823A (en) Weblog recording method, network access path determining method and related devices
CN111209600A (en) Block chain-based data processing method and related product
CN108133026B (en) Multi-data processing method, system and storage medium
CN108388657B (en) Cookie storage method, device, equipment and readable storage medium
CN103067465A (en) File sharing method and system
CN105991683A (en) Data transmission method and device
CN104811418A (en) Virus detection method and apparatus
CN115426374A (en) Service quality control method, device, equipment and storage medium
CN108306859B (en) Method, apparatus and computer-readable storage medium for limiting server access volume
CN104346228A (en) Application program sharing method and terminal
CN103746870A (en) CDN delivery network analysis method, file delivery control center and system
CN113746918A (en) Hypertext transfer protocol proxy method and system

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