Focus Global Community

Members Login
Username 
 
Password 
    Remember Me  
Post Info TOPIC: Question about setting a cookie


Senior Member

Status: Offline
Posts: 183
Date:
Question about setting a cookie
Permalink   
 


Hey Everyone,

I have a php page that I created a login for it uses a jquery drop down to show the form that displays the login and I am trying to fix it to work also if js is disabled. Right now it is set so that if java script is enabled and you click on a link (href="#") then the box drops down. However if js is disbaled i need that link to instead show (href="login.php").

My thought was to check if javascript is enabled by setting a cookie and then php will just check if that cookie is created. So i go and set my cookie using:

Code:
<SCRIPT LANGUAGE="JavaScript">
var dt = new Date(), expiryTime = dt.setTime( dt.getTime() + 1800000 );
document.cookie = 'JsCheck=' + 'Javascript Check' + ';expires=' + dt.toGMTString();
</SCRIPT>

Then right under that I do:


php Code:
<?php
if(isset($_COOKIE['JsCheck'])){
die('JS Enabled');  //The die is just here for testing purposes
}
?>

First I make sure that the cookie is not set and then with js enabled on my browser I go to my page. Once loaded I check my cookies and firefox reports back to me that my cookie was successfully created. However my php check did not trigger and kill the loading of the page. Once that is done though if I go and reload the page with the cookie already set php picks up the cookie and kills the refresh.

Is there a reason why this check does not work upon the initial loading when the cookie is set?


Thanks in advance,

Joe



__________________
Page 1 of 1  sorted by
 
Quick Reply

Please log in to post quick replies.

Tweet this page Post to Digg Post to Del.icio.us


Create your own FREE Forum
Report Abuse
Powered by ActiveBoard