HI,
I Have a javascript that sets a cookie.
What file would be the best way to do it
Thanks
HI,
I Have a javascript that sets a cookie.
What file would be the best way to do it
Thanks |
Let me explain in more details :
1- I have a javascript (I tried to find a php script that detect if flash is installed, but I found nothing that works, so I use java):
var MM_contentVersion = 6; var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0; if ( plugin ) { var words = navigator.plugins["Shockwave Flash"].description.split(" "); for (var i = 0; i < words.length; ++i) { if (isNaN(parseInt(words[i]))) continue; var MM_PluginVersion = words[i]; } var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion; } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) { document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag document.write('on error resume next \n'); document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n'); document.write('</SCR' + 'IPT\> \n'); } if ( MM_FlashCanPlay ) { document.cookie = "flashDetection" +"="+ "yes"; } else{ document.cookie = "flashDetection" +"="+ "no"; }
2- In a php file : if ($_COOKIE['flashDetection'] == "yes"){ some php actions }
3- The problem is that the cookie is written after the site loads, I have to refresh so that the php works.
Is someone knows how to fix this ?
|
That is actually normal. When a cookie is set, the page has to be reloaded to actually read that cookie, thus they cannot be placed on the same page. https://www.deanbassett.com |
Thanks a lot
it works perfectly. |