Share via

how to get unique session Id from azure b2c sign-in

Srivastava, Roshan (North Sydney) 26 Reputation points
2021-05-05T04:39:12.097+00:00

I am using azure b2c with web app integration with cookie based authentication. I am using standard sign-in user flow and i want to get unique session for every login so that i can tie up with customer journey and tracking for each login session. Also I have observed that If i delete all the cookie from the web app still the customer is logged in even though the request doesn't have any cookie and on the server side I am getting all the claim of the customer. So how does this authorization flow work as there are no cookie and bearer token in the header

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments

Answer accepted by question author

  1. ANUBHAV ADHYAYAN 81 Reputation points
    2021-06-06T13:48:05.197+00:00

    Hello @Anonymous ,

    I believe you have asked the same query on Stackoverflow it seems. Incidentally I was also searching for similar question and I stumbled on the question here.

    Disclaimer :- The following answer is provided for the benefit of the QnA community and was originally written by Brando Zhang on Stackoverflow.

    If you want to get a session id in your application, you could refer to below codes:

    Firstly, you should register the session in the startup.cs ConfigureServices method.

    services.AddSession(options =>  
    {  
        options.IdleTimeout = TimeSpan.FromSeconds(10);  
        options.Cookie.HttpOnly = true;  
        options.Cookie.IsEssential = true;  
    });  
    

    and add usesession method in the Configure method:

        app.UseSession();   
    

    Secondly, you could get the session id in controller:

        var re = HttpContext.Session.Id;  
    

    Notice: If you don't set any session in your controller, the sessionid will change for every request which sent from client side.

    102649-komm7.png

    For detailed discussion around this . Please visit the original query on stackoverflow.

    .

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.