Inconsistent jquery. getJson () sessions

Source: Internet
Author: User
Jquery. hello, everyone. I am a beginner in PHP and recently am working on a website. I used the following code to asynchronously request to register. php, but register. php and login. the sessionId printed by php is inconsistent. I have encountered this problem before, because the jquery version is too low, but now the highest version also has this problem. which expert can help me solve this problem.

$. GetJSON ("register. php", {username: username}, function (data ){
$ ("# Lgform"). submit (); // submit to login. jsp
});


Reply to discussion (solution)

The session has nothing to do with jquery. most of the problems are caused by your code. It can be pasted for analysis.

It seems to have something to do. I have met before, and its code is very simple. The session is configured in the conf. php file and introduced in both register. php and login. php.

Conf. php file
Ini_set ('session. cookie_domain ', 'localhost ');
Session_start ();
$ SessionId = session_id ();

After register. php receives the data
$ _ SESSION ["username"] = $ username;

After jquery returns data, it requests to login. php
$ _ SESSION ['username'] data is empty. the sessionId of login. php is inconsistent with the sessionId of register. php.

No one can answer this question, so few experts.

Please provide the complete test code. it is impossible for people to write code to verify what you cannot do.

This should only exist in IE!
Root cause:
The P3P (Platform for Privacy Preferences Project (P3P) specification) protocols supported by IE6 and IE7 prevent third parties from using cookies without Privacy security claims by default. Firefox does not currently support P3P security features, this problem does not occur in firefox. For more information about Mircosoft, see Privacy in Internet Explorer 6.
The solution is to output the host header declaration of P3P when the server responds:
Connect Baidu Library
Http://wenku.baidu.com/view/ea504514866fb84ae45c8d2c.html
Paste C # code: add it to the Ajax login page **. ashx code
If (context. Request. Browser. Browser. ToUpper (). Contains ("IE "))
Context. Response. Headers. Add ("P3P", "CP = cao psa our ");

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.