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 193 posts 469 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 733 posts 2844 karma points c-trib
    Sep 02, 2014 @ 14:58
  • David Brendel 792 posts 2970 karma points MVP 3x 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 193 posts 469 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 733 posts 2844 karma points c-trib
    Sep 03, 2014 @ 10:42
    Sören Deger
    0

    Hi Tom, 

    mark the solution post to solved, please ;-)

     

    Sören

Please Sign in or register to post replies

Write your reply to:

Draft