weixin_33688840 2017-12-06 15:37 采纳率: 0%
浏览 38

Cookies被删除

I have an asp.net mvc application and I have this strange thing that is happening and I don't know why.

Context:

I have a page that allows the user draw and edit images. This page has a feature that each 5 minutes, she made a ajax call to the server using jquery, saving the current state of the project on the database and another call to save an image of the project that is storage in a proper place.

Problem:

With the browser minimized, when this feature is launched, after the ajax call to the server, the cookie Customer is deleted. But when the chrome is maximized, this works fine.

Notes:

  1. This only happens when the browser is minimized
  2. This is happening, at least, in chrome and firefox.
  3. This is only happens on the production environment. On my local machine and on visual studio i cannot reproduce the issue
  4. The asp.net session cookie is mantainned

I know that is difficult for you to help only with this information, but, if you can give me clues it will be really helpful. I'm trying to expose the problem so we can match similar issues to find the best solution for this case.

Thank you in advance

[EDIT]:

I have some new about the issue:

  1. Using Chrome Version 63.0.3239.84 (Official Build) (64-bit);
  2. Firefox quantum 57.0 (64-bit);
  3. Contrary that I first thought, this is happens even if the browser is not minimized and precisely 3 mints after the page load (if I call the function)
  4. The cookie are not being deleted but the content of the cookie is: enter image description here
  5. This is a asp.net web application
  6. The console does not gives any errors
  7. The version of query is 2.1.3
  8. Follows the jquery call code:

    makeAjaxCall(ajaxData) {
    var localData = ajaxData.data ? ajaxData.data : {},
        urlVariables = {};
    
    localData.cmd = ajaxData.cmd;
    
    var controlerURL = ajaxData.uploadUrl ? HelperJSViewBag.getValue("ajaxCAllUploadURL") : ajaxData.controller;
    
    if (typeof ajaxData.data.urlVariables == "undefined")
        ajaxData.data.urlVariables = [];
    
    let editorVersion = "";
    let forceEditorVersion = "";
    
    if (typeof UrlParameters != "undefined") {
        editorVersion = UrlParameters.getInstance().editorVersion;
        forceEditorVersion = UrlParameters.getInstance().forceEditorVersion;
    }
    else if (typeof HLinks != "undefined") {
        editorVersion = HLinks.getUrlVariable("editorVersion");
        forceEditorVersion = HLinks.getUrlVariable("forceEditorVersion");
    }
    
    if (editorVersion.length > 0)
        ajaxData.data.urlVariables.push({
            name: "editorVersion",
            value: editorVersion,
        });
    
    if (forceEditorVersion.length > 0)
        ajaxData.data.urlVariables.push({
            name: "forceEditorVersion",
            value: forceEditorVersion,
        });
    
    if (typeof ajaxData.data.urlVariables != "undefined" && ajaxData.data.urlVariables.length > 0)
        for (var i = 0; i < ajaxData.data.urlVariables.length; i++)
            urlVariables[ajaxData.data.urlVariables[i].name] = ajaxData.data.urlVariables[i].value;
    
    localData = this.fillLocalData(localData);
    
    return $.ajax({
        type: 'POST',
        data: localData,
        url: controlerURL + "?" + $.param(urlVariables),
        success: function (data) {
            try {
                var result = JSON.parse(data),
                    status = result.status;
    
                delete result.status
                switch (status) {
                    case 1: ajaxData.sucess && ajaxData.sucess(result.data); break;
                    case 2: ajaxData.insucess && ajaxData.insucess(ajaxData.errorHandler && ajaxData.errorHandler.handle && ajaxData.errorHandler.handle(result)); break;
                }
            }
            catch (ex) {
                ajaxData.insucess && ajaxData.insucess(ajaxData.errorHandler && ajaxData.errorHandler.handle && ajaxData.errorHandler.handle(ex));
            }
        },
        error: function (data) {
            ajaxData.insucess && ajaxData.insucess(ajaxData.errorHandler && ajaxData.errorHandler.handle && ajaxData.errorHandler.handle(data));
        }
    });
    }
    
  • 写回答

2条回答 默认 最新

  • 10.24 2017-12-15 17:48
    关注

    I would like to see your code on the ASP.NET side, but without that, I can only guess: perhaps check to see if you are setting a cookie expiration date? Here is an example of a cookie that is created with 1 day expiration:

    Dim myCookie As HttpCookie = New HttpCookie("Customer")
    myCookie.Expires = Now.AddDays(1)
    Response.Cookies.Add(myCookie)
    

    If you omit myCookie.Expires property, the cookie "will expire when the user session expires", ref. https://msdn.microsoft.com/en-us/library/78c837bd.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB图像问题
  • ¥20 树莓派5做人脸情感识别与反馈系统
  • ¥15 selenium 控制 chrome-for-testing 在 Linux 环境下报错 SessionNotCreatedException
  • ¥15 使用pyodbc操作SQL数据库
  • ¥15 MATLAB实现下列
  • ¥30 mininet可视化打不开.mn文件
  • ¥50 C# 全屏打开Edge浏览器
  • ¥80 WEBPACK性能优化
  • ¥30 python拟合回归分析
  • ¥500 metaswitch 6010