以前的Session 對象使用時要打開瀏覽器的Cookie 支持,IE 的默認值是開啟。檢查Cookie 的功能是否被關閉的步驟如下:
1. 選擇IE 的「Tools」選單,點選「Internet Options」選項:
2. 按下「Security」頁簽里的「Custom Level...」按鈕:
3. 確認「Security Settings」窗口內「Cookies」群組里的「Allow cookies that arestored on your computer」和「Allow per-session cookies(not stored)」的Enable選項是否被核取,若無選取則在選取后按「OK」離開。
不過在ASP.NET 中就算不開啟瀏覽器的Cookie 支持也可以讓Session 動作,只要在Config.web檔案中加入< sessionstate cookieless="true" / >這個敘述就可以讓Session 不再依賴Cookie;但是此時的Config.web 文件一定要放在www 的根目錄里,也就是預設的C:\Inetpub\wwwroot 里。