2

Our app came out of web vulnerability assessment. The findings suggested that we should take care of persistent cookies; avoid them. Cookies are persisted by setting the Expires property to some future date. The cookie will have a key-name like this (its taken out from the VA report):

Cookie: http%3A%2F%2Fspsrvr%3A2222%2FDiscovery

Is there any central way of managing this? Via web.config or central administration? I am under the impression that is a sharepoint specific cookie.

2

There is no way to set this in SharePoint. It's hard coded.

I've had pretty good luck with the code below. An issue still remains if you are using blobcaching on your WFE's. The blobcache module actually returns early and my code never gets hit.

    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
        context.PostAuthenticateRequest += new EventHandler(context_PostAuthenticateRequest);
    }

    void context_PostAuthenticateRequest(object sender, EventArgs e)
    {
        HttpApplication app = sender as HttpApplication;
        RemoveCookie(app);
    }

    void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        HttpApplication app = sender as HttpApplication;
        RemoveCookie(app);
    }

    void RemoveCookie(HttpApplication app)
    {
        if (app == null) return;
        if (app.Response == null) return;
        if (app.Response.Cookies == null) return;

        try
        {
            if (app.Response.Cookies["WSS_KeepSessionAuthenticated"] != null)
            {
                app.Response.Cookies["WSS_KeepSessionAuthenticated"].Expires = DateTime.Now.AddDays(-1D);
            }

            if (app.Response.Cookies["MSOWebPartPage_AnonymousAccessCookie"] != null)
            {
                app.Response.Cookies["MSOWebPartPage_AnonymousAccessCookie"].Expires = DateTime.Now.AddDays(-1D);
            }                
        }
        catch { }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.