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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing window and refreshing parent page

Status
Not open for further replies.
Joined
Jul 28, 2005
Messages
358
Location
FR
Hi,

I have a login link that opens a popup so that the user can login (Client specified they wanted a popup not to have it on page). When they submit their login details, they are validated by a php script and if correct a session cookie is set which is then used by the parent windows script to display a shopping cart.

What I want to do, is if the login is succesful, to close the popup window and refresh the parent window so the cookie is recognised and the cart is shown. So, how do I get the window to close and the parent to refresh. The php for this is no problem, just the javascript hence why I have posted in this forum.

Thanks,

Richard
 
I think I may have sorted it by simply putting

Code:
<script>
top.opener.location.reload(true);
window.close()
</script>

in the php conditional that checks the login is valid.

Richard
 
Right,

Now I have a new problem. When I logout, I call the same page with a variable passed in the url which tells the page to process the logout script (this is all php). It then refreshes the page so that the property cart is gone from the page. However, when I try to login again the logout variable is still in the url so it logsout as soon as I login.

Can I strip the logout variable from the url using javascript so that when the page refreshes itself I don't have this problem. The url has other variables in it which are needed, it's just the last one '&logout=1' which I need to get rid of.

I am using
Code:
window.location.reload( true );
to refresh the page after I destroy the session cookie.

I hope this is clear, but if not I will try to rephrase it.

Richard
 
so you have a page [tt]www.somesite.com/page.html?blah=blah&logout=1[/tt] and you want to reload with [tt]www.somesite.com/page.html?blah=blah[/tt] ?

try this:

Code:
window.location = window.location.split("&")[0];



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
I think this is getting there. the url is actually more like
So, if I am thinking right (I'm not too good with javascript) the location.split wouldn't work as I have more than two variables in the url string.

What about if I replace the & in the location.split with &logout=1. Would that do it?

I'll have a try now and see if it sorts me out.

Thanks,

Richard
 
I know what you mean. The problem is that I want to go to the same page, and just get rid of the session cookie and display the page without the cart. I can't see how I could do the last bit server side.

I hav tried the javascript I mentioned but it doesn't seem to do the trick. The url still has logout=1 in it and the cart is still displayed. Also, when they login, they are still getting logged straight back out.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top