ident Posted November 25, 2009 Share Posted November 25, 2009 Basically my site is having a few bugs with how it displays IE. It works fine in FF. while i am sorting this i added a redirction page to alert the user. <?php function ae_detect_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } ?> <?php if (ae_detect_ie()) { ?> echo "<script language='javascript'> window.location = "http://www.url.com/Ie.php" </script>"; <?php } ?> Obviously each time they hit index.php it displays this. How can i add a varible or something so it only redirects them once. than ks Link to comment https://forums.phpfreaks.com/topic/182953-can-php-set-a-cookie-or-varible-so-i-only-perform-an-action-once/ Share on other sites More sharing options...
HokieTracks Posted November 25, 2009 Share Posted November 25, 2009 You could set a session variable and then check to see whether or not the session variable exists. The session variable, however, will last until they exit their browser. <?php session_start(); function ae_detect_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } ?> <?php if(is_null($_SESSION['viewed'])){ if (ae_detect_ie()) { ?> echo "<script language='javascript'> window.location = "http://www.url.com/Ie.php" </script>"; <?php $_SESSION['viewed'] = 1; } } ?> Link to comment https://forums.phpfreaks.com/topic/182953-can-php-set-a-cookie-or-varible-so-i-only-perform-an-action-once/#findComment-965696 Share on other sites More sharing options...
ident Posted November 25, 2009 Author Share Posted November 25, 2009 Your code still loads the redirect page Link to comment https://forums.phpfreaks.com/topic/182953-can-php-set-a-cookie-or-varible-so-i-only-perform-an-action-once/#findComment-965708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.