Cookie loss problem (authentication failure) authentication (user authentication information) will also lose _javascript tips

Source: Internet
Author: User

I wonder if you have been so embarrassed:

When your page certification is based on a cookie-like approach, such as form,windows integration certification, the following operations sometimes certification failure, authentication (user authentication information) lost, need to log in again
After the system is logged in normally:

First page (pagea.htm): After window.showModalDialog (), the second page pops up (pageb.htm)

Second page (pageb.htm): After window.open (), the pop-up window (pagec.htm) sometimes jumps to the login page

This should be because the different pages exist in different processes, resulting in the identity of the information is not synchronized, the certification failed, but this is a certain probability occurred, after the help of Ms Consultant, finally found a way:
Generally speaking, when ShowModalDialog (), the window as an object parameter into the pageb.htm, in the PageB, with this argument to open (), so the problem is solved
Specifically as follows:
-----------pagea.htm--------------
...
var obj = new Object ();
Obj.mytestwindowa = window;//This window into an object parameter
window.showModalDialog ("pageb.htm", obj, "");
...
----------------------------------

-----------pageb.htm--------------
...
var obj = window.dialogarguments;//Gets the parameters of the previous page
Obj.myTestWindowA.open ("pagec.htm"); ...
----------------------------------
  tested, no more identity loss, it's done!
  Attentive friends will find that such an operation will result in pagec.htm, because opener is not pageb.htm but pagea.htm, so can not use Window.opener and pageb.htm communication, and open ( And can't pass the object parameter, Panic!
But fortunately in JavaScript, the object is a tree, you can hang anything on its branches, so we can communicate with pageb.htm for pagec.htm, pageb.htm transformation   as follows:
----------- Pageb.htm--------------
...
var obj = window.dialogarguments;//Gets the parameters of the previous page
var Obj.myTestWindowA.myTestWindowB = new Object ();
Obj.myTestWindowA.myTestWindowB = window;//hangs pageb window under PageA window branches
Obj.myTestWindowA.open ("pagec.htm") (////////////////////////////
----------------------------------
  This allows you to communicate with the PageB page's objects in Pagec, such as Window.opener.myTestWindowB.document.getElementById ("TextBox1"). value= "OK"

Note:
1. This may be just a situation, may be open again ShowModalDialog may also lead to the loss of identity information, but we just pass the no problem window to the next page, the problem can be solved.

(See http://www.ourac.net/read.php?tid=45123&fpage=2for missing conditions)
2. It may also occur during session, see http://support.microsoft.com/default.aspx?scid=kb; en-us;196383

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.