PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Is it possible in PHP to check wether a page has a parent? I have a site that uses iframes in certain parts. The site has a timeout so after a certain time if left when the user clicks in one of the iframes it times out and takes them to the homepage - but that appears within the iframe!
What I need it to do is detect that its in an Iframe and if so refresh the parent not the child.
We are using DHTMLX with layouts and accordions. The Accordion Cells load from a seperate URL - they basically behave like iframes. Every page I load has the same check in it - which checks wether the users session has timed out or not? If it has then any action on that will redirect the page to the home page where they can log in again. However if this occures in the iframe the home page loads in the iframe. It should force the whole page to reload instead.
I suppose the way to do it would to have the detection on the home page so that if it finds itself loading into an iframe it would reload the parent. Is that possible using javavscript?
As far as I understand the JS dependance is not a problem for you so JS is the solution for you.
Let's set it like this. You have a user. His/Her session has expired and they click on a button/link in an iframe. What you shoud do is to check for Session expiration(Obviously you do it).
I suppose you use a cless for taht check. In the method by which you check whether a user has expired you should include a case in which instead of header(); you call a JS which gets your parent window object and redirects it to the home page. In order to do this you can raise a flag when a logout is called from an iframe or from the main windows.
Note:Try that and tell us whether it does the job(It must). If you come to something wiser I would be happy to share. This solution came first to my mind.