0

We have an aspx page that needs a cookie in order to start. Before redirecting to that page, we create the cookie and it is given on the response then the redirect to the page.

Form form = new Form { 
            FormID = dalObject.FormID, 
            PageName = dalObject.PageName, 
            ViewPageName = dalObject.ViewPageName };

        HttpCookie cookie = new HttpCookie("FormCookie");
        cookie.Expires = DateTime.Now.AddMinutes(1);

        if (dalObject.FormID==(int)Forms.SP_APP_FORM)
        {
            cookie.Values.Add("ApplicationRepositoryID",GetEncryptedToken(applicationRepositoryID.ToString()));
            cookie.Values.Add("UserDirectoryID", GetEncryptedToken(userDirectoryID.ToString()));
            cookie.Values.Add("FormID", GetEncryptedToken(dalObject.FormID.ToString()));

            if (applicationFormID.HasValue)
                cookie.Values.Add("ApplicationFormID", GetEncryptedToken(applicationFormID.ToString()));
        }
        form.PageCookie = cookie;
        return form;

The problem is that in the development environment it is working just fine, in production it is working too (for them), but if we try the production site, it does not work (from our development computers). We suspect the cookie doesn't get created. And this happens on 2 of 3 computers of the development. on one of them it is working. We tried to delete the cookies, clear cache, but no result.

Any ideas? Thanks

4

1 回答 1

0

我以前在我们的网站上看到过这个。在我们的案例中,客户端和服务器时钟明显不同步。服务器设置到期时间,客户端根据自己的时钟检查它,如果它超过(在你的情况下)一分钟太快,那么它会立即到期。

我们将 cookie 的到期时间设置得更远(比如一周或一个月),然后只在服务器上进行检查(因为它应该自我检查)。基本上,我们在 cookie 中添加了额外的数据(手动到期时间),服务器可以使用它来进行检查。如果您认为它已过期(您设置的一分钟),则服务器将删除(并忽略)它发送的 cookie。

我不知道这是否是解决问题的最佳方法,但它对我们有用。

顺便说一句,我们只在 IE 上发现了这个问题。

于 2012-08-06T12:56:26.233 回答