Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 414 posts 1655 karma points
    Jun 14, 2020 @ 04:38
    David Armitage
    0

    Umbraco 8 Session Cookie always null

    Hi Guys,

    A strange one here.

    I just noticed a bit of my code that stores data in the session was not working. It noticed the session was always null even though it had just bee set.

    I looked further into it and simplified everything to make sure it wasn't my code causing any problems.

    1. I create a session variable in my RenderMvcController Get method.

    Session["UMB8SR_PhotoUrl"] = "/test-url-here";

    1. In the same Get method I then double check the Session variable exists bu getting the session again. There is no problem there. It exusts

    if (Session["UMB8SR_PhotoUrl"] == null) { //do nothing for now }

    1. When I then refresh the page the whole session is null again.

    2. When I look in Chrome inspector I can see the url in the session section but there is no keys or variables at all.

    Has anyone got any ideas. This is driving me crazy trying to figure out what is wrong.

    enter image description here

  • David Armitage 414 posts 1655 karma points
    Jun 14, 2020 @ 05:09
    David Armitage
    0

    Hi Guys,

    Just adding to the issue...

    I tested some more. Mainly in different browsers. This just seems to be a Chrome thing.

    In my render mvc controller this code...

            if (HttpContext.Session["UMB8SR_PhotoUrl"] == null)
            {
                HttpContext.Session["UMB8SR_PhotoUrl"] = "/test-url-here";
            }
    

    Runs fine on firefox. So the first time I load the page it enters the if statement then if I refresh the page following the first load then debugger does not enter the if statement. (As we would expect)

    Then with Chrome the debugger enters the if statement every page load like the session is never getting stored.

    I tested on a number of my Umbraco 8 projects and the same for every one. I need to test on other versions on Umbraco. Maybe this is a bug if the recent version of Chrome.

    Can anyone else confirm if you are experiencing the same issue?

    Kind Regards

    David

  • David Armitage 414 posts 1655 karma points
    Jun 14, 2020 @ 05:57
    David Armitage
    100

    It may have been a bug with Chrome.

    I cleared all the cookies and history in Chrome and I cant seem to re-create the issue.

    Hopefully that's the end of it.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies