EchoFool Posted November 17, 2008 Share Posted November 17, 2008 Hey, I'm in an annoying situation where i cannot think what to do in order to solve my issue so hopefully someone here may have a solution. Currently my site can be viewed on an external site with my site withing an iframe. Now what i have is this on the file on my server: <?php require_once 'library/client/library.php'; session_start(); $_SESSION['Var'] = 1; ?> <iframe src ="http://www.domain.com" width="630" height="600" style="overflow-x: hidden;"> </iframe> ?> This is working perfectly but when $_SESSION['Var'] is set, a different CSS file is loaded so that the site loads and fits in the iframe perfectly. Now if a user leaves the site with the iframe and visits the main site normally, the $_SESSION['Var'] is still set and thus it loads the wrong layout. Is there a way I can check when the following situation occurs: if user views www.domain.com via iframe on secondary site if user views www.domain.com normally on browser That way i can unset $_SESSION['Var'] if its the latter. Perhaps theres a way in php to check if the site is in an iframe ? Any thoughts that may help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/133084-stuck-with-what-to-do/ Share on other sites More sharing options...
EchoFool Posted November 17, 2008 Author Share Posted November 17, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/133084-stuck-with-what-to-do/#findComment-692208 Share on other sites More sharing options...
craygo Posted November 17, 2008 Share Posted November 17, 2008 why not check the HTTP_HOST then set the session variable accordingly. <?php if($_SERVER['HTTP_HOST'] != "www.domain.com"){ $_SESSION['Var'] = 1; } else { $_SESSION['Var'] = 0; } ?> I am not sure what you code is like but something like above should work. Ray Quote Link to comment https://forums.phpfreaks.com/topic/133084-stuck-with-what-to-do/#findComment-692240 Share on other sites More sharing options...
EchoFool Posted November 17, 2008 Author Share Posted November 17, 2008 Im afraid that didnt work. The application is from facebook which is calling my file which contains the script shown above... so that script is actually on my site, but facebook loads it into their application so everyone in essence is hosted on my server and loaded from it. So the only way to solve it is possibly some way to know if my site is being loaded in an iframe rather than a normal browser window? If thats even possible server side? Quote Link to comment https://forums.phpfreaks.com/topic/133084-stuck-with-what-to-do/#findComment-692318 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.