Page 1 of 1

2 iframes loading the same local php file but only 1 works

Posted: Wed Mar 21, 2012 11:01 am
by thinsoldier
My Test Setup

site.com/admin/index.php is a login form that posts to /admin/login.php which then redirects to start.php if the login details were correct.

site.com/admin/iframetest.php contains 2 iframe tags. Both iframes pull /admin/iframecontent.php

My Problem

For some reason when I first log in and immediately go to iframetest.php, the first iframe shows iframecontent.php properly and the second iframe shows either start.php (as if I had just logged in) or index.php (as if I had been logged out and booted to the login form again).

Any idea what would cause this?

Any tips on how I could track down the cause? I had considered maybe I could add some kind of logging function to my config.php which is included at the top of all files in the test setup but not sure what I should be looking for.

Update
* I've made all the pages show me the session ID so when the wrong page loads in the 2nd iframe I can see if maybe it's using a different session id. It is not. All files report the same session ID. So now I'm thinking there's something wrong with me logic for checking if a person should be logged in or not.
* It's not always that iframe 1 works and iframe 2 doesn't. Sometimes it's the other way around.

Re: 2 iframes loading the same local php file but only 1 wor

Posted: Tue Mar 27, 2012 8:45 am
by phphelpme
Would be ideal to see some code so I can replicate the issue you are having here.

It should not happen as standard because as you already know your in the same browser with the same windows which would use the same session id etc. You can load the same page 50 times in 50 iframes if required, so it must be something in your code which is causing it.

Without some code we can not help you very much.

Best wishes

Re: 2 iframes loading the same local php file but only 1 wor

Posted: Tue Mar 27, 2012 9:33 am
by thinsoldier
I'm still trying to narrow down the possible areas of code that would be the source of the problem so I can put together a simple code example that exactly reproduces the problem. That's the real problem. I can't consistently reproduce the issue.

At first I thought it was only an IE problem but it has happened twice in the last week in Firefox on OS X.

I believe it is tied to another issue my IE 7 users are having where they click on a link to look at a record and instead wind up at start.php

It appears that when they click any link the browser/server for some reason does not see the session cookie so my login logic does not think they are logged in and header redirects them to index.php but when they get to index.php the session is available so it thinks they're still logged in and sensibly header redirects them to start.php.
I've put a print_r($_SERVER) on every page and I can see that when this happens, the Referrer values is the url that they originally clicked.
This happens sort of frequently in IE7 and IE8 but never in Safari, Chrome, or Firefox in Windows or OS X.

While looking into the iframe issue I found lots of info about IE ignoring session cookies unless extra header() info is sent if the iframe is on another domain. But everything is on the same domain in my case.

Re: 2 iframes loading the same local php file but only 1 wor

Posted: Tue Mar 27, 2012 10:06 am
by phphelpme
Yes, you are correct that header information must be sent etc but not in your current situation. I believe it will be an issue with your login script and checking of the session that exists. If they are being redirected to your index page but then are being recognised that the session exists then its your coding that is doing this, not the browser.

It might be wise to post your login script, the functions used, and the check session scripts along with any code that you place at the top of every page. Only then can we start to deal with your issue.

I can create a script with loggin features now, load that page, login, then the start.php loads as many iframes as possible for me, but does not redirect etc because the sessions are recognised. So it must be some little code snippet somewhere that is causing this for you.

Best wishes

Re: 2 iframes loading the same local php file but only 1 wor

Posted: Fri Apr 27, 2012 6:00 pm
by thinsoldier
Thanks for your attention. I haven't had a chance to revisit this bug yet, too busy working on other parts of the project (which has had 3 additional sub-projects added to it since then!) I hope you're still around when I finally get back to this bug. Thanks.