The setcookie in IE is invalid.

Source: Internet
Author: User
User logon with invalid setcookie under IE
Login. php
setcookie("YP_account",$account,(time()+3600),"/",".yourone.cn");setcookie("YP_userid",$userid,(time()+3600),"/",".yourone.cn");setcookie("YP_type",$type,(time()+3600),"/",".yourone.cn");

Jump to index. php after setting cookie
print_r($_COOKIE);

The returned null value is the cookie set on the login. php page.

Excuse me, what's wrong with this question?

It's okay if I use two virtual domain names locally.
The above code is put on the Internet server for testing.

Note: The same code has no problem under FF.


Reply to discussion (solution)

Output before setcook ??
Are the two pages different in time? // This is less likely
Does ie reject cookies?

Add one sentence
Header ('p3p: CP = "CURa ADMa DEVa PSAo PSDo our bus uni pur int dem sta pre com nav otc noi dsp cor "');


I have 2 domain names now
Http://test1.yourone.cn/
Http://test2.yourone.cn/
Login. php under test2

$ Account = $ _ POST ['username']; $ password = $ _ POST ['password']; $ rs = curlApp ('http: // test1.yourone.cn/index.php? A = webLogin & m = Login & g = Home & act = 1 & username = '. $ account. '& password = '. $ password); $ rsarr = explode ("|", $ rs); if ($ rsarr [0]! = "" & $ Rsarr [0] = "OK") {$ account = $ rsarr [1]; $ userid = $ rsarr [2]; $ type = $ rsarr [3]; setcookie ("YP_account", $ account, (time () + 3600), "/", ".yourone.cn "); setcookie ("YP_userid", $ userid, (time () + 3600), "/", ".yourone.cn"); setcookie ("YP_type", $ type, (time () + 3600), "/", ".yourone.cn"); $ js-> alertWithRelocate ("logon successful ",".. /index. php ");} else {$ js-> alertWithBack ($ rs );}


Use a curl request to obtain the verification result from the verification under test1 and return the logon information.
The verification result is echo "OK | $ account | $ userid | $ type ";
Set the cookie under test2 for obtaining information

When I log on to test2 and set the cookie under this domain name, do I not need header p3p?
What I need to achieve is
If test1 has a logon cookie information after successful login, call test2 and test3 to set the cookie page.
If test2 has logon cookie information after successful login, Call test1 and test3 to set the cookie page.
If test3 has a logon cookie after successful logon, Call test1 and test2 to set the cookie page.

The code is as follows:
In test1

 

In test2
 


In test3
 



FF functions are implemented, but IE does not work.
For example, test2 test3 fails to be set for all cookies on test1.

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.