Apparently as most people, I'm using the same yaf_User table for my individual site registration as well as for the forum.

What I want to do now is, when a user logs into the site it automatically logs them in to the YAF forum. I have found where it calls yaf_user_login (which really does nothing more than authenticate the user) and drilled down further and found where yaf_pageload is called. Now yaf_pageload seems to be where the magic happens because it is what updates the yaf_active table. I can manually call yaf_pageload and get it to add my logged in user to there, but still when I go to the forum/defaul.aspx page, it doesn't show me as logged in.

What am I missing? Is there another field/stored procedure/class or something that gets set when a user is officially logged in? I've also tried to set it through the cookie but that didn't work either. I'm having a heck of time tracing through the code...esp. being as I can't run it locally in the IDE.

Any thoughts or clarification on the login process would be extremely helpful.

I'm trying basically this same thing. Have you been able to figure it out yet? It's giving ne a headache.
Doing the same. My anal self wants to modify the yaf_User table to just Users. I've removed the <form>... within my web.config and it still goes to the pages/logic.ascx control to login. I'm guessing it has something in the Forum.cs? Did you look at that? I'll keep you posted on what I find.

anyone had any luck trying this, i too am stuck at this point, im looking more at trying to decipher the cookie and creating a session to pass into yaf but i cant see any code where the cookie or session is used.

any help would be greatly appreciated
  •  Mek
  • 100% (Exalted)
  • YAF Developer
bump. You guys had any luck?

I've abandoned the trying to read the YAF cookie route for my site due to the fact YAF uses the Forms Authentication which I won't be able to reproduce as my site is on a different subdomain.

I've pretty much resigned myself to modifying the YAF login page to also save out a cookie with the information I need for my portals as well as leaving it's own code and I was going to cheat by using the YAF Login page to do all the work because it nicely includes a referral page which will bounce it back wherever it came from.

I'll have to do the same for the logout button. It's a bit messy but will at least achieve what I want.


would return you got google after loginning in. Then the idea would be to read the cookie I had saved out for checking whether a user is logged in. Since my sites written in ASP (for now), I think this will be the only way I can do this.

Any thoughts on this cludge?


"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
I have done with automatic-login membership
I received reference in http://www.codeproject.c...aspnet/SingleSignon.aspx .

**In First Web Application**
1. fill in web.config
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx" name=".ASPXAUTH" timeout="2880" />

<machineKey validationKey="282487E295028E59B8F411ACB689CCD6F39DDD21E6055A3EE480424315994760ADF21B580D8587DB675FA02F79167413044E25309CCCDB647174D5B3D0DD9141" decryptionKey="8B6697227CBCA902B1A0925D40FAA00B353F2DF4359D2099" validation="SHA1"/>

2. Login Page I have defined at [WebApplication1]/login.aspx]
Login Authenticate fill in event :

FormsAuthentication.SetAuthCookie([username], false);
System.Web.HttpCookie MyCookie =System.Web.Security.FormsAuthentication.GetAuthCookie(User.Identity.Name.ToString(),false);
MyCookie.Domain = "";//the second level domain name
//I try to my computer after publish my site

**In Second WebApplication**
1. web.config
<deny users="?"/>
<authentication mode="Forms">
<forms loginUrl="../[ProjectName1]/login.aspx" name=".ASPXAUTH" />
"../" Explain that come back from [ProjectName2] to[ProjectName1]/login.aspx
<!-- machineKey same in [First Web Application]-->
<machineKey validationKey="282487E295028E59B8F411ACB689CCD6F39DDD21E6055A3EE480424315994760ADF21B580D8587DB675FA02F79167413044E25309CCCDB647174D5B3D0DD9141" decryptionKey="8B6697227CBCA902B1A0925D40FAA00B353F2DF4359D2099" validation="SHA1"/>

That's all my solution with Single Sign On with Membership of YAF or other web site.

You can ask me if you can't solve this problem
Dear naphong,

Thanks a lot for your wonderful post.
It helped me to solve my issue.
I also faced the same issue but I fixed the issue as follows:

1.) Add connection string with name ‘yafnet’
<add name="yafnet" connectionString="Data Source=.;Initial Catalog=YAF;Integrated Security=True" providerName="System.Data.SqlClient"/>

2.) Override Membership provider
<membership defaultProvider="YafMembershipProvider" hashAlgorithmType="SHA1">
<add name="YafMembershipProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" requiresUniqueEmail="true" useSalt="true" type="YAF.Providers.Membership.YafMembershipProvider"/>

<add name="AspNetSqlMembershipProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" enablePasswordReset="false" enablePasswordRetrieval="true" maxInvalidPasswordAttempts="5" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="5" passwordAttemptWindow="15" passwordFormat="Encrypted" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" type="System.Web.Security.SqlMembershipProvider"/>

<roleManager enabled="true" defaultProvider="YafRoleProvider">

<add name="YafRoleProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" type="YAF.Providers.Roles.YafRoleProvider"/>
\ <add name="AspNetSqlRoleProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" type="System.Web.Security.SqlRoleProvider"/>

<profile enabled="true" defaultProvider="YafProfileProvider" inherits="YAF.Utils.YafUserProfile">
<add name="YafProfileProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" type="YAF.Providers.Profile.YafProfileProvider"/>
<add name="AspNetSqlProfileProvider" applicationName="YetAnotherForum" connectionStringName="yafnet" type="System.Web.Profile.SqlProfileProvider"/>

3.) Add following keys in appsettings section of Web.Config
<add key="YAF.DatabaseObjectQualifier" value="yaf_" />
<add key="YAF.DatabaseOwner" value="dbo" />
<add key="YAF.ConnectionStringName" value="yafnet" />
<add key="YAF.MembershipProvider" value="YafMembershipProvider" />
<add key="YAF.RoleProvider" value="YafRoleProvider" />
<add key="YAF.ProviderProvider" value="YafProfileProvider" />
<add key="YAF.ProviderExceptionXML" value="ProviderExceptions.xml" />

After doing this much of stuff we have applied the same settings (Membership Provider / Database in use for provider (User Repository) in our Web project, which were being used in YAF Forum.

4.) Since YAF uses Forms Authentication and cookies to store the user information of logged in User.
So we will apply same mechanism in our MVC application as well, we will use Forms Authentication (with cookies) in our MVC application. So add the following tag under <System.web> section

<authentication mode="Forms">
<forms name=".YAFNET_Authentication" protection="All" timeout="43200" cookieless="UseCookies"/>

Here in the above tag we have given the name property as ‘.YAFNET_Authentication’ , which denotes the name of cookie which will store user information after successful login. The same tag is in use in Forum project.

5.) Now we have synced both (Forum as well as MVC 4.0 project) in terms of Membership framework.

After doing this much of task you will be enable to achieve the desired functionality.
gahlouta thank you for this answer. Could you please give us an example of a login form with mvc please ?

Thanks in advance

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved