Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popups and session ends

Status
Not open for further replies.

Modica82

Technical User
Jan 31, 2003
410
GB
Hi,

I have a login are that gives the user there own personal area of a website. They have a menu, and several of the menu options open popup windows which contain data. My problem is, if the session runs out and the user refreshes this page then my login page appears in the popup up. What i want to do is close the pop up window, and refresh the parent page which would redirect to the login page. I know the sytax Javascript wise, but how do i check that the user is authenticated in the popup (normal aspx) page. Apologies if the question sounds dumb, but for some reason today my head will not remove itself from my backside and i cannot think it through.

Thanks,

Rob

---------------------------------------
 
In the pop-up page, check if the user is authenticated on the page load event. If they are not, use ClientScript.RegisterClientScriptBlock to register the javascript that will close the window and the redirect the parent. You can close the window using window.close and access the other page by using window.opener. Ask in the JavaScript forum if you have any specific problems with the actual JavaScript function.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
hmmmm... "how do i check that the user is authenticated in the popup (normal aspx) page"

Can you in the page load event in code behind do whatever you do to authenticate?

If User.Identity.IsAuthenticated Then

Which is part of the System.Security.Principal.IPrincipal.Identity (namespace)

I do this on a popup I have I also call a web service method to verify current user.

Another option I have used was to put the current user form the parent page in session and retrieved that session on the child page.

I might be misunderstanding your question. You might not be using code behind and need to authenticate in javascript code. How are you opening the child window? If you are using the open.nodalDialog you have an array of params sent to the child page which you can utilize.


 
Another option I have used was to put the current user form the parent page in session and retrieved that session on the child page.

Thats pretty much what I do. But I am dealing with an Intranet only site so I really don't have to lock down everything like an internet site. But what I do is pass the user into a session from page to page then if the session has expired I pass them back to my Login.aspx page.

But again, It's an intranet site that's why I do it that way.

 
Hi all,

I have placed the following code in my page_load event:

Code:
        If Not Context.User.Identity.IsAuthenticated Then
            'The User is not authenticated so lets shut this window down and refresh the parent.
            RegisterStartupScript("StartUp", "<script language='JavaScript'>window.close();window.opener.location.reload(true);</script> ")
        End If

the problem i have is if the user has logged out or the session has ended then this peice of code never gets executed, the page just returns to my login.aspx page (as i have setup in my web.config). I am unsure of how i can do change this so that it calls my code first before it decideds to redirect to the login page as i want to close the popup down and redirect the calling page to the login.aspx.

THanks for your help.

ROb

---------------------------------------
 
i would suggest pasting a code in the login page rather than in other pages.

try this in ur login page:
<script>
if(opener)
{
//login page has been opened in popup. Therefore its because of a logout.
opener.location.href='login_page_path'
window.close()

}
</script>

Known is handfull, Unknown is worldfull
 
Thanks vbKris,

my code is

Code:
        If Not IsPostBack Then

            Dim chkExtended As Boolean

            'Identify if we have come from an "Extended" page, 
            chkExtended = CBool(InStr(adminURL, "extended") > 0)

            'It has so close the window.
            If chkExtended Then
                RegisterStartupScript("StartUp", "<script language='JavaScript'>window.close();window.opener.location.reload(true);</script> ")
            End If

        End If

Seems to work, but need a little testing! thanks again!

Rob

---------------------------------------
 
welcome.

note: Add the close() after other JS commands...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top