I have a rails 2.1 application have the following code: class CookieController < ApplicationController def index extra = cookies["extra"] end end
<%= "index" %> <script type="text/javascript"> set_cookie(); display_cookie();
function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function createCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function set_cookie() { createCookie("extra","testbbb",100); createCookie("another","testanother",100); createCookie("ptheme","ccc",100); } function display_cookie() { alert(document.cookie) var x = readCookie('ptheme')
} </script>
The problem is that I can not see the cookie in controller when using ie, I can not see the cookie when use firefox. Any suggestion? Thanks in advance