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仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题