Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:13:04+00:00 2026-05-24T18:13:04+00:00

I am creating a login and the storing the user details in a cookie

  • 0

I am creating a login and the storing the user details in a cookie using this code

if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
{
   //string useremail = Convert.ToString(txtUserName.Value);
   Session.Add("useremail", txtUserName.Value);
   FormsAuthenticationTicket tkt;
   string cookiestr;
   HttpCookie ck;
   tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now, 
     DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data");
   cookiestr = FormsAuthentication.Encrypt(tkt);
   ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
   if (chkPersistCookie.Checked)
     ck.Expires=tkt.Expiration; 
   ck.Path = FormsAuthentication.FormsCookiePath; 
   Response.Cookies.Add(ck);
}

I am also creating a session Session.Add(“useremail”, txtUserName.Value);
After succesfull authentication it is redirected to user.aspx
I want to read the useremail value in the user.aspx page but when I tried to access the value in the user page it is not showing useremail field.

protected void Page_Load(object sender, EventArgs e)
    {
        if
            (Session["useremail"] == null) Response.Redirect("Home.aspx");
        else

            BindGridView(useremail);
    }

And this is my webconfig:

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

Correct me if i am doing any wrong. And also please tell me how to pass the useremail value to the user.aspx page so that I can pass that value to gridview function

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:13:05+00:00Added an answer on May 24, 2026 at 6:13 pm

    Just change it to

    protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["useremail"] == null)
                Response.Redirect("Home.aspx");
            else
                BindGridView((string)Session["useremail"]);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently creating a Login form and have this code: string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
I am creating a cookie and storing the value of username after succesfull login.
I am creating forms authentication cookies using the following code: string formsCookieStr = string.Empty;
I'm creating a login application on Eclipse using Google Web Toolkit(GWT). The code checks
I am creating a login system for a web application using PHP. My question
I'm creating a login for a website using PHP but when I try to
I've been reading this post Creating a login form in CodeIgniter based on Ion
So I'm creating a site where users must login. If the user wishes that
I am creating a new Silverlight 4 business application using RIA services. This will
I'm creating a user system for Rails, and login, sign up etc... all works.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.