YAFLogo

Demigod
  • Demigod
  • 95.60001% (Exalted)
  • YAF Commander Topic Starter
12 years ago
Just upgraded to 1.9.5. From what I can tell the UserID (from yaf_User) is not held in the session anywhere. I need it to be in the session so the rest of my website knows who is logged in.

Question 1:
Is the Login1_Authenticate method in login.ascx.cs the best place to deal with doing this?

Question 2:
After the user is logged in, is this var already held somewhere by YAF that I could easily get at other than yanking it out of the DB myself using the ProviderKey for the logged in user?
Sponsor

Demigod
  • Demigod
  • 95.60001% (Exalted)
  • YAF Commander Topic Starter
12 years ago
For others that need the answer, I answered my own question in this thread:

http://forum.yetanotherforum.net/yaf_postst5489_v1-9-3-3-Membership-Login-Question.aspx 
Chetan Bavarva
7 years ago
try this solution:



protected void Page_Init(object sender, EventArgs e)
{
    if (HttpContext.Current.User != null && Session["userId "].ToString() == "")
    {
		var userName = HttpContext.Current.User.Identity.Name;
				 
		var userDetail = "SELECT us.userid FROM yaf_User us " + "WHERE us.Name = '" + userName + "'";
var userInfo = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(SQLConnection, System.Data.CommandType.Text, userDetail).Tables[0];

		Session["userId"] = userInfo.Rows[0]["userid"].ToString();
    }
}

Chetan Patel
Custom software company India 
iFour Technolab Pvt. Ltd
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
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