Copied to clipboard

Flag this post as spam?

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


  • asaf peretz 2 posts 72 karma points
    Nov 13, 2021 @ 16:33
    asaf peretz
    0

    Distributed session

    I would like to save user sessions into redis. So i registered a service overriding the default IDistributedCache

    services.Add(ServiceDescriptor.Singleton

    And still session is not effected and saved locally

    The same solution in a clean MVC site works

    Any suggestions ?

    Thanks,

  • Yakov Lebski 594 posts 2350 karma points
    Nov 14, 2021 @ 17:29
    Yakov Lebski
    0

    you can try somthing like this

    var redisConfigurationOptions = ConfigurationOptions.Parse("localhost:6379");
    
                services.AddStackExchangeRedisCache(redisCacheConfig =>
                {
                    redisCacheConfig.ConfigurationOptions = redisConfigurationOptions;
                });
    
                services.AddSession(options => {
                    options.Cookie.Name = "myapp_session";
                    options.IdleTimeout = TimeSpan.FromMinutes(60 * 24);
                });
    
  • asaf peretz 2 posts 72 karma points
    Nov 14, 2021 @ 21:27
    asaf peretz
    0

    Thanks,

    Already tried that, and after setting a value to session I cannot locate it when inspecting my redis server.

    Although when setting a value through the DistributedCache Service directly it works.

    I think that some where under the hood umbraco is already enabling the session, i don't know if that is the reason why it is not working

  • Yakov Lebski 594 posts 2350 karma points
    Nov 14, 2021 @ 22:42
    Yakov Lebski
    0

    But you want to use session, you can use it at

    var value = HttpContext.Session.GetString("Test");
    
  • 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