ASP in the Ajax way to get the implementation of the session code _ Application skills

Source: Internet
Author: User
Since I am using the FF browser, I have not found any problems. Last week submitted to the user to see, said that the use of IE login after the invalid, big surprise. The result is really like this. It's embarrassing.
The login code is as follows:
Copy Code code as follows:

Whether a session exists from the server query
J.ajax ({
Type: "Get",
URL: "Sessioncheck.asp",
Data: "",
timeout:1000,
Error:function () {
Alert (' Sorry, server is busy now! ');
},
Success:function (Comments_data) {
if (Comments_data = = 1) {
El.createdialog (opts);
J.startover ();
}
else{
var sql = Selectsql (searchkey,stype);
window.location.href = SQL;
}
}
});

Roughly so sessioncheck.asp inside is to check the session, the code is as follows:
Copy Code code as follows:

If session ("username") = "" Then
Response.Write ("1")
Else
Response.Write ("2")
End If

The result is to use IE this session ("username") anyway no, timeout set up also useless.

Go online to check for a long time, found that the same problem is quite a lot, finally find out the reason: caching problem.

When an asynchronous get gets fetched, if the URL is unchanged, it is the information in the cache that is being invoked directly, and then it causes the value to not be in the session.

Solution that's easy, Google "asp clear cache" a lot.
Finally, a paragraph was added to the sessioncheck.asp, as follows:
Copy Code code as follows:

Response.Buffer =true
Response.ExpiresAbsolute =now ()-1
Response.expires=0
Response.cachecontrol= "No-cache"
If session ("username") = "" Then
Response.Write ("1")
Else
Response.Write ("2")
End If
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.