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 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同