在Firefox中读取cookie的问题

在Firefox中读取cookie的问题

问题描述:

In my application I'm trying to read the cookie value but in firefox4 it's reading it like

PHPSESSID=6obpuf73q9l7oelqjp49vi4f57; __utmc=111872281; __utma=111872281.346828356.1310972579.1310977402.1310984221.3; __utmz=111872281.1310972579.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); plugins_pn=0; __utmb=111872281.100.10.1310984221; pages_pn=0; selection=contract-hire

and in chrome it's reading it like

PHPSESSID=6obpuf73q9l7oelqjp49vi4f57;
selection=contract-hire

Some times in FF4 it works fine but 99% of the time it fails. Can somebody tell me how I can solve this problem.

edit

i am getting the cookie val as

var cookval = document.cookie.split('=')[2];
    var sel = cookval.split(';')[0];
//sel contains the desired value

在我的应用程序中,我正在尝试读取cookie值但在firefox4中它正在读取它像 p> \ ñ

  PHPSESSID = 6obpuf73q9l7oelqjp49vi4f57;  __utmc = 111872281;  __utma = 111872281.346828356.1310972579.1310977402.1310984221.3;  __utmz = 111872281.1310972579.1.1.utmcsr =(直接)| utmccn =(直接)| utmcmd =(无);  plugins_pn = 0;  __utmb = 111872281.100.10.1310984221;  pages_pn = 0;  selection = contract-hire 
  code>  pre> 
 
 

在chrome中它正在读取它 p>

  PHPSESSID = 6obpuf73q9l7oelqjp49vi4f57; 
selection = 合同雇用
  code>  pre> 
 
 

有时在FF4中它工作正常但99%的时间失败。 有人可以告诉我如何解决这个问题。 p>

编辑 strong> p>

我的cookie值为 p>

  var cookval = document.cookie.split('=')[2]; 
 var sel = cookval.split(';')[0]; 
 //  sel包含所需的值
  code>  pre> 
  div>

if you want to read and set cookie in javascript, use these little functions: http://www.w3schools.com/js/js_cookies.asp

(When I use it, I also do a replace(/\+/g,' ') to get string with spaces)