[go: up one dir, main page]

CN111353117B - WEB cross-domain cookie management system based on key-value type memory database - Google Patents

WEB cross-domain cookie management system based on key-value type memory database Download PDF

Info

Publication number
CN111353117B
CN111353117B CN202010155501.2A CN202010155501A CN111353117B CN 111353117 B CN111353117 B CN 111353117B CN 202010155501 A CN202010155501 A CN 202010155501A CN 111353117 B CN111353117 B CN 111353117B
Authority
CN
China
Prior art keywords
key
cookie information
information
cookie
memory database
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
CN202010155501.2A
Other languages
Chinese (zh)
Other versions
CN111353117A (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.)
Nanjing Lianchuang Digital Technology Co ltd
Original Assignee
Nanjing Lianchuang Digital Technology 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 Nanjing Lianchuang Digital Technology Co ltd filed Critical Nanjing Lianchuang Digital Technology Co ltd
Priority to CN202010155501.2A priority Critical patent/CN111353117B/en
Publication of CN111353117A publication Critical patent/CN111353117A/en
Application granted granted Critical
Publication of CN111353117B publication Critical patent/CN111353117B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a WEB cross-domain cookie management system based on a key-value type memory database, which creates a key-value memory database storage key value through a session key and an access domain name, directly stores cookie information returned by a target domain as value information in the memory database, and can load the cookie information returned by the target domain according to the key and add the cookie information to a target domain request calling parameter when accessing the same target domain server next time to execute a calling request of a target domain address. When a product has multiple cross-domain accesses, cookie loading can only aim at the current target domain, and cookie information of other target domains is ignored, so that memory occupation space of the session is greatly reduced, the session information deserialization speed is improved, and cookie information serialization, deserialization performance and memory overhead are further reduced.

Description

WEB cross-domain cookie management system based on key-value type memory database
Technical Field
The invention relates to the technical field of information, in particular to a WEB cross-domain cookie management system based on a key-value type memory database.
Background
The essence of Cookie is a data block which is created by a WEB server when a user logs in WEB, and the data block is transmitted to a client through http/https header information and is kept in a local file by a client browser. Cookie information is associated with a user access domain and is time-sensitive, and the time-sensitive will automatically fail. When the client accesses the target domain, the client needs to fill corresponding cookie information in an http/https request header.
With the continuous development of the internet plus service, more and more situations exist when one WEB client needs to access WEB information of multiple domains at the same time, so that the problem of cross-domain WEB access occurs. In order to solve the problem of cross-domain of a front-end WEB terminal, the prior art provides the following scheme: and establishing a local proxy server to enable the browser to directly access the single domain of the local proxy server, wherein all the accesses of other domains are completed by the proxy of the local proxy server. In the scheme, the local proxy server serves as a server of the user client and also serves as a client of the target domain access request, the proxy server proxies the client to complete the request of the target domain and returns the request result to the client, and meanwhile, the proxy client manages cookie information of the target domain, wherein the cookie information is added into request header information when the target domain requests, and the cookie information is kept updated after the target domain requests respond.
However, the above method for managing cookies by the proxy server usually stores the target domain cookie information in the proxy server session, and the management method can be effectively used in small and medium-sized service systems, and the use of this scheme in large-sized systems will increase the storage and access burden of the session, and is not favorable for implementing session sharing in the server cluster mode.
Disclosure of Invention
The purpose of the invention is as follows: the invention aims to overcome the technical defects and provides a technical scheme capable of solving the problem of managing a plurality of cookies corresponding to a plurality of domain names during WEB cross-domain access without increasing session storage and access burden.
The technical scheme is as follows: in order to achieve the purpose, the technical scheme provided by the invention is as follows:
the WEB cross-domain cookie management system based on the key-value type memory database comprises:
the system comprises a client, a local proxy server, a key-value type memory database and at least one target domain WEB server;
when a client accesses a certain target domain WEB server X for the first time, a local proxy server agent client initiates a calling request to the target domain WEB server, acquires cookie information A of the current login and response information T of the current request returned by the target domain WEB server after the request is successful, generates a unique key jointly according to the cookie information A and the domain name of the target server, and stores the cookie information A to a key-value type memory database by using the key; then, the local proxy server creates a session object for the login of the client, takes the session key as cookie information B of the login of the client to the local proxy server and feeds the cookie information back to the client, and writes response information T into response information T1 of the local proxy server to the client to feed the response information back to the client;
when the client accesses the target domain WEB server X again, the client firstly sends a target domain access request containing cookie information B and a target domain name to the local proxy server; the local proxy server calculates a key according to the cookie information B and the domain name of the target domain, loads cookie information A from a key-value type memory database according to the key and fills the cookie information A in the head of the request information of the target domain, then initiates a call request of the target domain, obtains response information T2 returned by the target domain WEB server and cookie information C of the target domain WEB server which logs in at this time, and updates the cookie information C into the key-value type memory database; finally, the local proxy server feeds back cookie information D logged in by the client to the client, and writes response information T2 into response information T3 of the local proxy server to the client, and feeds back the response information to the client.
Further, before the local proxy server reads cookie information in the key-value type memory database according to the key, firstly, judging whether the cookie information exceeds the timeliness of the cookie information; if not, directly reading; and if so, deleting the corresponding cookie information from the key-value type memory database and ignoring the reading.
Further, when updating the cookie information C into the key-value type memory database, first taking out the cookie information a, merging the cookie information a and the cookie information C into cookie information E, and then storing the cookie information E into the key-value type memory database by using the key of the cookie information a, covering the original record of the cookie information a.
Specifically, the key-value type memory database is a redis memory database.
Has the advantages that: the key-value memory database storage key is created through the session key and the access domain name, the cookie information returned by the target domain is directly stored in the memory database as the value information, and compared with the prior art that the cookie information returned by the target domain is stored in the session, the scheme has the following advantages:
1. the invention greatly reduces the memory occupation space of session.
2. The invention greatly improves the speed of deserialization of the session information and reduces the cost of a CPU because the occupied amount of the session memory is reduced.
3. When a product has multiple cross-domain accesses, the cookie loading can only aim at the current target domain, and the cookie information of other target domains is ignored, so that the scheme further reduces the cookie information serialization, deserialization performance and memory overhead.
Drawings
Fig. 1 is a schematic diagram of a WEB cross-domain cookie management system architecture based on a key-value type memory database according to an embodiment of the present invention;
fig. 2 is a flow chart of the operation of the system according to an embodiment.
Detailed Description
The invention aims to provide a scheme for managing cross-domain cookies through a key-value type memory database, which is applied to a system architecture of cross-domain http/https requests by using a local proxy server as a front-end processor. The WEB cross-domain cookie management system based on the key-value type memory database comprises a client, a local proxy server, a target domain WEB server and the key-value type memory database. The workflow of the management system comprises the following steps performed in sequence:
A. the client browser accesses the local proxy server and transmits request information accessed by the target server to the local proxy server as a parameter, the client accesses the local proxy server and checks whether cookie information of the proxy server exists locally, and if the cookie information exists, the cookie information is carried in the request information.
B. The local proxy server checks whether the request information contains cookie information, if the request information contains the cookie information and the cookie information contains session key information of the proxy server user, a session key value is taken out, and then the step C is executed; if not, directly transferring to the step E.
C. And splicing the target domain address information and the session key information into character string information, wherein the character string information is used as a key for accessing the storage record of the cookie information of the corresponding target domain server in a key-value type memory database.
D. And D, acquiring cookie information stored in the memory database from the memory database according to the memory database storage key acquired in the step C, if the stored information exists and does not exceed the set failure, adding the acquired cookie information as request information for accessing the target domain service to the WEB request information in the step E, and if the acquisition fails, ignoring the request information.
E. And assembling the target domain request information and initiating a call request of http/https to the target domain.
F. If the request fails, directly jumping to the step I for processing; and D, if the request is successful, the request response result contains cookie information, the cookie information is taken out, if the cookie information is taken out from the memory database in the step D, the cookie information of the 2 parts is merged, and if the cookie information does not exist, the returned cookie information is taken as the final cookie information.
G. And if the processing result of the step F has an effective cookie information to be stored and updated and the session of the local proxy server does not exist, creating the session, taking out the session key information, and outputting the session key information as the cookie information to the browser client in the step I.
H. If the processing result of the step F has an effective cookie to be stored and updated, generating a storage key for storing cookie information in the memory database according to the scheme of the step C, and updating the cookie information returned by the request for the target domain to the existing cookie information; after the cookie information is updated to the memory database, the timeliness of the cookie information needs to be updated aiming at the stored information, and the effective acting time point of the cookie is the effective duration appointed by the cookie plus the current time point.
I. And processing the request response result, and returning the response result to the browser client as the response result of the http/https request of the browser client to complete a WEB calling request.
In order to more clearly illustrate the technical solution of the present invention, the following description is further provided with reference to the accompanying drawings and the detailed description.
Example (b): the embodiment of the invention establishes a system structure as shown in figure 1, a local proxy server is developed and realized by NodeJS, and the domain name of the proxy server is assumed to be proxy.com; the target servers have 2, one is a jboss server, assuming the domain name is a.com, the other is a tomcat server, assuming the domain name is b.com. URL (Uniform resource locator)http://a.comThe address on the home proxy server is mapped intohttp://proxy.com/abiz,URL http://b.comThe address on the home proxy server is mapped intohttp://proxy.com/bbiz. For the target addresshttp://a.com/helloThen converted into a pairhttp://proxy.com/abiz/helloTo access (c).
The WEB access interaction flow in this embodiment is shown in fig. 2.
1. Suppose that a client browser executes a WEB request for the first time, the request address ishttp://proxy.com/abiz/ helloThe processing steps are as follows:
(11) receiving client browser by NodeJS proxy serverhttp://proxy.com/abiz/helloAnd (6) requesting.
(12) The request information does not contain the cookie information of the current user in the NodeJS proxy server, and the proxy server skips the processing logic of the cookie of the target domain and directly executes the cookie processing to the target domainhttp://a.com/helloThe WEB request of (1).
(13) The returned information after the WEB request is successful contains cookie information of the current user a.com domain, and the proxy server creates the cookie information of the current user on the proxy server:
key is JSSOSIONID
The value is 666 afffd-7 b47-4f37-aab7-1682f0d9 befa.
(14) The target domain cookie storage key generation rule is { target domain name } @ { JSESSIONID }, namely:
{a.com}@{666adffd-7b47-4f37-aab7-1682f0d9befa}
and taking { a.com } @ {666 addfd-7 b47-4f37-aab7-1682f0d9befa } as a key, and storing cookie information returned by the current user target domain request to a redis memory database.
(15) Http will be executed: com/hello output to http: and C, in response information of the com/abiz/hello request, outputting the cookie information created in the step C to a client browser to complete the WEB request.
2. The user again performs the request to the target domain, assuming the request address ishttp://proxy.com/abiz/hiThe processing steps are as follows:
(21) receiving client browser by NodeJS proxy serverhttp: com/abiz/hi request
(22) Com domain, and extracting cookie information 666 affd-7 b47-4f37-aab7-1682f0d9befa with key being JSESSIONID from the cookie information.
(23) And generating a character string { a.com } @ {666 affd-7 b47-4f37-aab7-1682f0d9befa } as a redis in-memory database access key according to the target domain cookie storage key generation rule.
(24) And (3) extracting cookie information of the a.com target domain corresponding to the current user from the memory database according to the memory database access key { a.com } @ {666 affd-7 b47-4f37-aab7-1682f0d9befa } and checking the timeliness of the cookie information.
(25) Adding the valid target domain cookie information obtained in step (24) to the target addresshttp://a.com/ hiIn the request of (2), the execution target addresshttp: com/hi request
(26) And after the WEB request is successful, returning information containing cookie information of the current user a.com domain. Firstly, taking { a.com } @ {666 addfd-7 b47-4f37-aab7-1682f0d9befa } as key to take out original cookie information from an internal memory database, adding the cookie information newly returned at this time into the original cookie information, updating the combined cookie information into a redis internal memory database by taking { a.com } @ {666 addfd-7 b47-4f37-aab7-1682f0d9befa } as key, and updating the timeliness of the storage record.
(27) Http will be executed: com/hi returned information is output to the pairhttp://proxy.com/abiz/hiAnd in the response information of the request, simultaneously outputting cookie information of the current user on the NodeJS proxy server to a client browser to complete the WEB request.
3. Com request to another target domain again, assuming the request address ishttp://proxy.com/ bbiz/hiThe processing steps are as follows:
(31) receiving client browser by NodeJS proxy serverhttp; com/bbiz/hi request
(32) Com domain, and extracting cookie information 666 affd-7 b47-4f37-aab7-1682f0d9befa with key being JSESSIONID from the cookie information.
(33) And generating a character string { b.com } @ {666 affd-7 b47-4f37-aab7-1682f0d9befa } as a redis in-memory database access key according to the target domain cookie storage key generation rule.
(34) Fetching cookie information of a b.com target domain corresponding to a current user from the memory database according to a memory database access key { b.com } @ {666 affd-7 b47-4f37-aab7-1682f0d9befa }, wherein the memory database has no related data, and directly executing the operation of the cookie information on the b.com target domain corresponding to the current userhttp://b.com/hiThe WEB request of (1).
(35) And after the WEB request is successful, returning information containing cookie information of the b.com domain of the current user. And updating b.com returned cookie information to a redis memory database by taking { b.com } @ {666 addfd-7 b47-4f37-aab7-1682f0d9befa } as a key and taking { b.com } @ {666 addfd-7 b47-4f37-aab7-1682f0d9befa } as a key, and updating the timeliness of the storage record.
(36) Http will be executed: com/hi returned information is output to the pairhttp://proxy.com/bbiz/hiAnd in the response information of the request, simultaneously outputting cookie information of the current user on the NodeJS proxy server to a client browser to complete the WEB request.
The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.

Claims (4)

1. WEB cross-domain cookie management system based on key-value type memory database, characterized by comprising: the system comprises a client, a local proxy server, a key-value type memory database and at least one target domain WEB server;
when a client accesses a certain target domain WEB server for the first time, a local proxy server agent client initiates a calling request to the target domain WEB server, acquires cookie information A of the current login and response information T of the current request returned by the target domain WEB server after the request is successful, generates a unique key jointly according to the cookie information A and the domain name of the target server, and stores the cookie information A to a key-value type memory database by using the key; then, the local proxy server creates a session object for the login of the client, takes the session key as cookie information B of the login of the client to the local proxy server and feeds the cookie information back to the client, and writes response information T into response information T1 of the local proxy server to the client to feed the response information back to the client;
when the client accesses the target domain WEB server again, the client firstly sends a target domain access request containing cookie information B and a target domain name to the local proxy server; the local proxy server calculates a key according to the cookie information B and the domain name of the target domain, loads cookie information A from a key-value type memory database according to the key and fills the cookie information A in the head of the request information of the target domain, then initiates a call request of the target domain, obtains response information T2 returned by the target domain WEB server and cookie information C of the target domain WEB server which logs in at this time, and updates the cookie information C into the key-value type memory database; finally, the local proxy server feeds back cookie information D logged in by the client to the client, and writes response information T2 into response information T3 of the local proxy server to the client, and feeds back the response information to the client.
2. The WEB cross-domain cookie management system based on the key-value type memory database according to claim 1, wherein before the local proxy server reads cookie information in the key-value type memory database according to a key, whether the cookie information exceeds the timeliness of the cookie information is judged; if not, directly reading; and if so, deleting the corresponding cookie information from the key-value type memory database and ignoring the reading.
3. The key-value-memory-database-based WEB cross-domain cookie management system according to claim 1, wherein when updating cookie information C into the key-value-memory database, cookie information A is first taken out, the cookie information A and the cookie information C are combined into cookie information E, and then the cookie information E is stored into the key-value-memory database by using the key of the cookie information A, covering the original cookie information A record.
4. The key-value memory database-based WEB cross-domain cookie management system according to claim 1, wherein the key-value memory database is a redis memory database.
CN202010155501.2A 2020-03-09 2020-03-09 WEB cross-domain cookie management system based on key-value type memory database Active CN111353117B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010155501.2A CN111353117B (en) 2020-03-09 2020-03-09 WEB cross-domain cookie management system based on key-value type memory database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010155501.2A CN111353117B (en) 2020-03-09 2020-03-09 WEB cross-domain cookie management system based on key-value type memory database

Publications (2)

Publication Number Publication Date
CN111353117A CN111353117A (en) 2020-06-30
CN111353117B true CN111353117B (en) 2021-04-02

Family

ID=71195970

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010155501.2A Active CN111353117B (en) 2020-03-09 2020-03-09 WEB cross-domain cookie management system based on key-value type memory database

Country Status (1)

Country Link
CN (1) CN111353117B (en)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9792425B2 (en) * 2010-11-02 2017-10-17 Ca, Inc. System and method for controlling state tokens
CN102682009B (en) * 2011-03-11 2017-02-15 腾讯科技(北京)有限公司 Method and system for logging in webpage
CN107948167B (en) * 2017-11-29 2020-11-06 浙江数链科技有限公司 Single sign-on method and device
CN108259616B (en) * 2018-01-26 2021-06-15 中企动力科技股份有限公司 Session sharing method and device, electronic equipment and readable storage medium
CN109246076B (en) * 2018-08-01 2022-11-04 北京奇虎科技有限公司 Method and device for single sign-on to multiple systems
CN110347466A (en) * 2019-07-04 2019-10-18 绿漫科技有限公司 A method of for web page 3D Dynamic Display text

Also Published As

Publication number Publication date
CN111353117A (en) 2020-06-30

Similar Documents

Publication Publication Date Title
CN105812351B (en) Realize the shared method and system of session
US8583810B2 (en) Session affinity cache and manager
CN103064960B (en) Data base query method and equipment
CN112114979A (en) Remote procedure call method and device
US11689626B2 (en) Transport channel via web socket for ODATA
WO2015101151A1 (en) Session processing method, device and system
US20080288470A1 (en) Method and System for Distributed Dns Resolution
CN109451014B (en) WebService agent system and transparent agent method thereof
CN106911735B (en) Data acquisition method and device
CN111294372B (en) Method, device and system for realizing cache in proxy server
WO2018035799A1 (en) Data query method, application and database servers, middleware, and system
CN112866421B (en) Intelligent contract operation method and device based on distributed cache and NSQ
CN113329081A (en) Block chain service access method, device and computer readable storage medium
CN112799860A (en) Method for realizing service callback based on message queue and search engine
CN112702441B (en) Container-based access data processing method, device, system and storage medium
CN112988378A (en) Service processing method and device
CN114281854A (en) Data query method, system, equipment and medium based on polymorphic cache
CN103561083A (en) Internet of things data processing method
CN117520683A (en) AB test shunt management method, device, equipment and storage medium
CN111353117B (en) WEB cross-domain cookie management system based on key-value type memory database
US8127304B2 (en) Mapping and communicating data from a user interface to an application program
CN114282147A (en) A cookie management method and device based on iOS system
Baraki et al. Sam: A semantic-aware middleware for mobile cloud computing
CN115309373A (en) A method and device for accessing a web page application, a storage medium, and a computer device
CN115563412A (en) Access method, proxy server, electronic device and storage medium

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
CB02 Change of applicant information

Address after: 210019 4th floor, building 1, 69 Aoti street, Jianye District, Nanjing City, Jiangsu Province

Applicant after: Nanjing Lianchuang Digital Technology Co.,Ltd.

Address before: 210019 4th floor, building 1, 69 Aoti street, Jianye District, Nanjing City, Jiangsu Province

Applicant before: NANJING LIANCHUANG INTERNET TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant