, we use the following methods to create cookies on a third-party website.
In the above demonstration, you can also perform this operation on your local machine. You only need to make the following modifications:
Run the following command notepad C:/Windows/system32/Drivers/etc/hosts to open the hosts file. Make sure that the following two lines are added to the hosts file:
127.0.0.1 a.net127.0.0.1 B .com
What if I solve this problem?
A very simple solution is to modify the http://a.net/WebAp
In actual work, there are many requirements like this. For example, we have two domain names. We want to automatically complete the login of another domain name after one domain name login, that is, the PASSPORT function.
I only write a rough one. For the convenience of testing, edit the hosts file and add the test domain name (C: WINDOWSsystem32driversetchosts)
127.0.0.1 www.a.com127.0.0.1 www. B .com
First, create the_setcookie.php file with the following content:
// Header (P3P: CP = "
Sièscoperto Fai del Tuo meglio con il motore diesel sviluppato molti loro bit occasione quasi tutti apprezzato. Orologi antiquato motore diesel che sono stati giàora notevolmente cercato e sono rinomati anche oggi. Nella successiva intera guerra mondiale, motore diesel sviluppato un ' eccellente posizione di pertinenza di loro stessi, SE Mplicemente in Via di sviluppo servizi Militari insieme con il designer inizio orologi di Pertinenza militari. Che sono sempre stati riconosciuti per la loro qu
----------------------------------------------------------------------Header ("P3p: Cp = Cura ADMA Deva psao psdo our bus uni pur int DEM sta pre com nav OTC Noi DSP cor ");Header ("Set-Cookie: Test = Axis; expires = sun, 23-dec-2018 08:13:02 GMT; domain = .a.com; Path = /");?>----------------------------------------------------------------------Visit the above test process twice againYou can see that the second packet has sent the cookie that you rec
gmtcontent-type:text/htmlconnection:keep-alivevary:accept-encodingx-powered-by:php/ 5.3.29p3p:cp= "CURa ADMa DEVa Psao psdo our BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR" set-cookie:ape__session=k 44G3EKLSERT1FGBJHL061L4F4; path=/; Domain=.apelearn.comexpires:thu, 1981 08:52:00 Gmtcache-control:no-store, No-cache, Must-revalidate, Post-check =0, pre-check=0pragma:no-cache[[emailprotected] vhost]# curl ask.apelearn.com-i//Direct Connect http
open synchronous login application of the callback file uc.php received will be decrypted and decrypted well, you can actually write the code yourself. The code for this uc.php callback file does not have to be written in their format. You can also Write your own code for example, I just follow the session to do the synchronous landing
Copy Code code as follows:
function Synlogin ($get, $post) {
$uid = $get [' uid '];
$username = $get [' username '];
if (! Api_synlogin) {
What is P3P?
P3P (Platform for Privacy Preferences) is a recommended standard for privacy protection published by the public to provide privacy protection for users. The idea of the P3P standard is that the privacy policy of the WEB site should inform visitors about the types of information that the site collects, what information will be provided to whom, how long the information will be retained and how much information is used, such as the site should do such as "This site will monitor the pa
Recently, I was working on a project where my website is www.a.com, but I had to get the cookie from www. B .com for a long time. I worked with my colleagues. It's done.I used Java to add the following words to the www.a.com/a.vmfile:
The link in SRC can be a page or an action in B. I use an action. In the action of B .com, my code is as follows:Public actionforward getsidanduserid (actionmapping mapping, actionform form,Httpservletrequest request, httpservletresponse response ){String cartsid
synlogin ($ get, $ post) {Global {1} g; If (! Api_synlogin) {return api_return_forbidden;} header ('p3p: Cp = "Cura ADMA Deva psao psdo our bus uni pur int DEM sta pre com nav OTC Noi DSP cor "'); $ cookietime = 31536000; $ uid = intval ($ get ['uid']); $ query = DB: Query ("select uid, username, password from ". DB: Table ('uc _ members '). "Where uid = '$ uid'"); if ($ member = DB: Fetch ($ query) {dsetcookie ('auth ', authcode ("$ member [Password
placed on our own servers, but all source code is encrypted!
Finally, I checked the relevant information and found that in IE, to ensure security, I blocked the use of IFRAME to generate a third-party domain COOKIE. to solve this problem, MS requires that as long as the HTTP HEADER is in, set the P3P header to generate a third-party COOKIE through IFRAME.
In PHP, the P3P HEADER is set as follows:
Header ('p3p: CP = "CURa ADMa DEVa PSAo PSDo our bus u
decrypted and decrypted after you can actually write your own code this uc.php callback file code does not have to follow their format to write you can also self- Write your own code, for example, I'm doing a synchronous landing based on the session.
Copy CodeThe code is as follows:
function Synlogin ($get, $post) {
$uid = $get [' uid '];
$username = $get [' username '];
if (! Api_synlogin) {
return Api_return_forbidden;
}
Header (' p3p:cp= ' CURa A
synchronous login. in the application editing of uc, there is an option "allow synchronous login to this application", which won't happen here. after setting, we need to pay attention to uc. top configuration in php, marked in red:
Ucenter synchronous login and logout configuration
One step cannot be achieved without synchronization. Then we are looking at the corresponding two methods.
Function synlogin ($ get, $ post) {global $ _ G; if (! API_SYNLOGIN) {return API_RETURN_FORBIDDEN;} header (
workload. You only need to set the p3p HTTP HeaderIn the implicit IFRAME, you can set the cookie across domains. They used the following content: P3p: Cp = 'cura ADMA Deva psao psdo our bus uni pur int DEM sta pre com nav OTC Noi DSP core' ASP directly adds a header declaration in the header to test the validity. PHP should be written as follows:Header ('p3p: Cp = CaO PSA our '); ASP. NETInCodeAdd response. addheader ("p3p", "cp = CaO PSA our") o
, I blocked the use of IFRAME to generate a third-party Domain COOKIE. To solve this problem, MS requires that as long as the HTTP HEADER is in, set the P3P header to generate a third-party COOKIE through IFRAME.
In PHP, The P3P HEADER is set as follows:
Header ('p3p: CP = "CURa ADMa DEVa PSAo PSDo our bus uni pur int dem sta pre com nav otc noi dsp cor "');
Note: The P3P must be added to the file where the Cookie is generated in the third domain. Oth
trace during testing will reduce the workload of many Tests.You only need to set the P3P HTTP Headerto successfully set the cookie across domains within the implied iframe. The content they use is:p3p:cp= ' CURa ADMa DEVa Psao psdo our BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR 'ASP directly in the head with a head statement, test effective.PHP, it should be the following wording:Header (' P3p:cp=cao PSA our ');Asp. NET wordsBy adding Respon
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.