title: Access javascript cookie in module file in drupal
body: <p>Hi i am getting this strange problem. I am setting a cookie in external javascript file with current user time. I want this time to be available to the server so i am retrieving this using a php cookie.</p>
  
  <p>I am able to fetch the value but only if i refresh the browser 2 times. If i change my current system time, and then refresh the page i still see old time,but when i refresh again then i see updated time.</p>
  
  <p>I am doing something like this:
      enter code here</p>
  
  <p>External js file</p>
  
  <pre><code>var now=new Date();
  currTime=now.getHours();
  document.cookie = "currentTime = " +currTime;
  </code></pre>
  
  <p>module file</p>
  
  <pre><code>$current_time = $_COOKIE["currentTime"];
  echo $current_time;
  </code></pre>
  
  <p>I am calling the external js file in hook_nodeapi() using drupal_add_js</p>
  
  <p>As I said, I am able to get the updated value of current time from cookie but only if I refresh 2 times.</p>
  
  <p>What could be the problem?</p>
  
  <p>thanks</p>