PHP Session Clash With JavaScript Cookies
<p>I'm trying to maintain the position of the vertical scroll bar so user need not to scroll to where they were when the page auto-refresh. This is the first time I'm using JavaScript so I haven't written anything yet to make the scroll bar function work but tried to test using cookies tutorial on the Internet like simple cookies tutorial to ask for your name and then the page will display our your name on the alert box. </p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
function WriteCookie()
{
  if( document.myform.customer.value == "" ){
  alert("Enter some value!");
  return;
}

cookievalue= escape(document.myform.customer.value) + ";";
document.cookie="name=" + cookievalue;
alert("Setting Cookies : " + "name=" + cookievalue );
}

function ReadCookie()
{
  var allcookies = document.cookie;
  alert("All Cookies : " + allcookies );

  // Get all the cookies pairs in an array
  cookiearray  = allcookies.split(';');

  // Now take key value pair out of this array
  for(var i=0; i&lt;cookiearray.length; i++){
  name = cookiearray[i].split('=')[0];
  value = cookiearray[i].split('=')[1];
  alert("Key is : " + name + " and Value is : " + value);
  }
}


//--&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="myform" action=""&gt;
Enter name: &lt;input type="text" name="customer"/&gt;
&lt;input type="button" value="Set Cookie" onclick="WriteCookie();"/&gt;
&lt;input type="button" value="Get Cookie" onclick="ReadCookie()"/&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When I click on "Get Cookie" button, the alert will list out PHPSESID value and some other cookies value that I've tested earlier using a different. So I use print_r to display out the $_COOKIE array and discovered the JavaScript cookies are added to PHP's cookies as well. Is there anyway to create cookies using JavaScript without having to affect PHP's cookies? </p>
