简体   繁体   中英

Window.Open Killing Session and Cookies

I am trying to open a new window from code behind when the user clicks on a link button, but my application cookies and session is killed as user cannot do anything on the request page but i can see the window correctly with the response URL. Why is this happening and during the response I am not doing anything with the cookies. I was using the following post Response.Redirect to new window

        string url = "XYZ"
        string target = "";
        string windowFeatures = "menubar=0,scrollbars=1,width=780,height=900,top=10";
        script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
        script = String.Format(script, url, target, windowFeatures);
        ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);

Your session is actually stored in an asp.net cookie, so that makes me think your cookies aren't valid in the new window.

For some reason, is your URL different? Cookies aren't shared across domains, so if your main app is at "123.com" and your new window is at "XYZ.com", they won't have access to each other's cookies. That means no session, etc.

If you're not on different domains, then there is something else happening (specific code) that's wiping out your cookies. For example, if for some reason, your new window is opening in a different browser (which would take some interesting code) or if your browser is wiping cookies.

If you need more help, post more of the code so we can get more context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM