Copied to clipboard

Flag this post as spam?

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


  • Thomas Beckert 176 posts 441 karma points
    Sep 02, 2014 @ 12:17
    Thomas Beckert
    0

    addMemberToCache / Code Authentication in umbraco 7

    Hi,

    how do I automatically login a user in my c# code?

    In older Version, ich could just do this:

    Member m = Member.GetMemberByName("username",true).First();
    Member.AddMemberToCache(m, false, new TimeSpan(10, 0, 0, 0, 0));

    But in 7 it is recommended to use Memberservice.

    Anyone has a code example for me how to do it in seven?

    Tanks.

  • Sören Deger 726 posts 2833 karma points c-trib
    Sep 02, 2014 @ 14:58
  • David Brendel 786 posts 2949 karma points c-trib
    Sep 02, 2014 @ 15:40
    David Brendel
    100

    The link Sören provided should show how to do the trick. But it seems that the link is somewhat broken while he has done the copy/paste of it.

    So to make it short: Mermbers.Login(username,password); should do the trick in v7.

    Where "Members" is an instance of the MembershipHelper provided by your controller, view and so on.

     

  • Thomas Beckert 176 posts 441 karma points
    Sep 03, 2014 @ 10:22
    Thomas Beckert
    0

    Hi David, hi Sören,

    works great. Thanks for the support!

     

    Tom

  • Sören Deger 726 posts 2833 karma points c-trib
    Sep 03, 2014 @ 10:42
    Sören Deger
    0

    Hi Tom, 

    mark the solution post to solved, please ;-)

     

    Sören

  • 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