How does phpcookie cross-origin?

Source: Internet
Author: User
How does phpcookie cross-origin? Php COOKI cross-origin



Please give me some guidance. How to operate.


In addition, I will explain in detail the parameter requirements and problems of the fields in php setcookie.


For example: setcookie ("name", "value", time () + 3600, "path", "domain", "http ");


Mid-term domian requirements. For example, I have two websites, demo.xx.com admin.xx.com, and how to set domain.


.Xx.com.



Reply to discussion (solution)

Setcookie ("name", "value", time () + 3600, "/", "xx.com ");

Setcookie ("name", "value", time () + 3600, "/", "xx.com ");

Is this feasible. Can it be cross-origin? Have you tested it/

Yes. test it by yourself.

Yes. test it by yourself.

OK. Let me test it.

Jsonp is required for cross-origin cookie.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

Jsonp is required for cross-origin cookie.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp... How to get it.

Yes. test it by yourself.



I tested it. no .. Hms.org.cn. you can set the domain name in xxx.hms.org.cn.

However, it cannot be obtained in demo.hms.org.cn. To COOKIE

Reference the reply from hellodifa on the fifth floor: jsonp is required for cookie cross-origin.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp... How to get it.
For the sake of security, the browser does not support cross-origin cookie from website a to website B. However, if both website a and website B are yours, cross-origin is supported, however, you need to modify the information of website B.
There are many examples online, such as: http://www.nowamagic.net/javascript/js_UseJsonpCrossDomain.php

Reference the reply from xviphackl on the 6th Floor: reference the reply from hellodifa on the 5th floor: jsonp is required for cross-domain cookie.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp... How to get it.
For security reasons, the browser does not support cross-domain cookie seeding from website a to website B, but such ......


Thank you very much for the information you have found. now I understand the principles of JSONP.


Let me explain my problem. what I need to do now is.


Station A and Station B. station A is in charge of frontend B is in charge of backend


Station A has only one index. php file, and Station B is responsible for processing the entire site. They process different domain names.


I log on to site A and Site B (if I access site B directly, it works ).

However, the logon fails.


My initial solution was to use JS to send Site B's COOKIE value to site A. site A sent the COOKIE value for login, but it still solved the problem.


Can you understand this.


Reference the reply from xviphackl on the 6th Floor: reference the reply from hellodifa on the 5th floor: jsonp is required for cross-domain cookie.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp... How to get it.
For security reasons, the browser does not support cross-domain cookie seeding from website a to website B, but such ......


Correct a small problem,


Yes. log on from site A. A message is displayed, indicating that the operation is successful but the operation is not successful.


If you log on directly from site B, you can log on successfully.


Station A has only one file and stores the results to be processed from Station B (file_get_contents) on site.

Reference the reply from hellodifa on the eighth floor: reference the reply from xviphackl on the sixth floor: reference the reply from hellodifa on the fifth floor: jsonp is required for cross-domain cookie.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp... How to get it.
The browser is not supported for security reasons ......

If site a already has Site B cookies, but it cannot be captured on site B, it may only be a problem where Site B captures the cookies, and whether or not all cookies are transmitted ..

Reference the reply from xviphackl on the 10th floor: reference the reply from hellodifa on the 8th floor: reference the reply from xviphackl on the 6th Floor: reference the reply from hellodifa on the 5th floor: jsonp is required for cookie cross-origin.
Setcookie ("name", "value", time () + 3600, "/", "xx.com") cannot be transferred across others' domain names.

How to test jsonp ........


Well, thank you !! I will check it. It is not a problem to capture data.

Site A print COOKIE Site B also print COOKIE


Log on from station A, and the COOKIE of Station B is empty. (it is reasonable to say that both websites already have cookies and access site B from station, the COOKIE printed on site B should be able to read why the COOKIE in the previous domain is empty .).

I guess this is the reason ,,


Station A only has one to capture data... Site B is the specific implementation method. Why can't site B obtain the COOKIE used to access site A from site?

It is reasonable to say that the COOKIE domains on both sides are set the same. Why can't they be obtained?



Station A only has one to capture data... Site B is the specific implementation method. Why can't site B obtain the COOKIE used to access site A from site?


A uses curl capture? Pass the parameter cookie in curl.
If a crawls something from B and a does not pass it to bcookie, B cannot know what cookie a has ..



Station A only has one to capture data... Site B is the specific implementation method. Why can't site B obtain the COOKIE used to access site A from site?


A uses curl capture? Pass the parameter cookie in curl.
If a crawls something from B and a does not pass it to bcookie, B cannot know what cookie a has ..


The file_get_contents function does not use CURL to capture data. is it necessary to use CURL for data interaction?





This is accessed by site,

File_get_contents is used to capture information from a website. it is equivalent to directly entering an address in the browser for request. it is certainly unable to obtain the cookie of your server.
For example, how do you know the cookies of your computer when you access a website through your browser.

OK, taught. Now, I know which part has gone wrong. thank you first.


Let's get it done first. check it out...

File_get_contents is used to capture information from a website. it is equivalent to directly entering an address in the browser for request. it is certainly unable to obtain the cookie of your server.
For example, how do you know the cookies of your computer when you access a website through your browser.

Thank you for your sincerity. The problem is solved. Which is your reason.


File_get_contents does not pass the COOKIE value. Let Site B not know what COOKIE site A is.


Thanks again.

I also encountered this function problem. if the project fails, could you give me a simple and meticulous example? I am very grateful ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.