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 6959185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:14:17+00:00 2026-05-27T15:14:17+00:00

heey, i am doing a project for school witch includes a login in asp.net

  • 0

heey, i am doing a project for school witch includes a login in asp.net with a SQL server database, i have a login name and a password in the database, i heard this was only possible using cookies, i have look for a week now and it should be ready the 22 of december 2011.
i have a query and i want the result to be the cookie if i try this each time i get the result -1 if i put the anwser in a GridView i get the good result.
this is the code on the Btn_Click as far as i have it:

   protected void btnInloggen_Click(object sender, EventArgs e)
    {
        string sEMail = txtUserEMail.Text;
        string sPassword = txtPassword.Text;
        gvCookie.DataSource = SQL_codes.Inloggen(sEMail, sPassword);
        gvCookie.DataBind()//this was to test my query;

        HttpCookie cookUserName = new HttpCookie("Username");
        cookUserName.Value = Convert.ToInt16(gvCookie);//thought something liek this would do it but it doesn't so what i want is the result of the query here
        Response.Cookies.Add(cookUserName);

    if (Request.Cookies["Username"] !=null)
    {
        string sName = Request.Cookies["Username"].Value;
        Response.Write(sName);
    }
    }

and this is my how i think i should use my query:

    public static DataTable Inloggen(string sEMail, string sPassword)
    {
        string sql = string.Format("select OpdrachtGever.opdrid from OpdrachtGever where OpdrachtGever.eMail = '{0}' and OpdrachtGever.Password = '{1}'", sEMail, sPassword);
        SqlDataAdapter da = new SqlDataAdapter(sql, SQL_codes.GetConnection());

        DataTable dt = new DataTable("reserveringen");
        da.Fill(dt);
        return dt;
    } 

(it’s in dutch because i am dutch sorry)

now i though maybe i can put the result into a variable but i can’t vindt how this works

it would be awesome if you guys(or girls) could help me because i am completly stuck

  • 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-27T15:14:17+00:00Added an answer on May 27, 2026 at 3:14 pm

    Cookies are used to for persistent data. Without cookies, a web server wouldn’t be able to tell one client from another.

    Manually managing cookies can be messy, especially for stuff like logins. You can instead use session variables via ASP.NET, which abstracts away the management of cookies in a secure manner and lets you treat an object like an object.

    Session[“blnIsLoggedIn”] = MethodValidateLogin(strUserName, strPassword);

    Then check on page load if they are logged in

    if(Session[“blnIsLoggedIn”] != null and (boolean)Session[“blnIsLoggedIn”] == true)
    Do This
    else
    Do That

    There are many more important things to know about for logins, like hashing and salting passwords, protecting against SQL Injections(parameterized inputs), and stuff. But it sounds like you’re just doing a beginner’s project, so I won’t explain them but leave you with the terms.

    P.S. I don’t do much ASP.NET and what I do make is intranet only, so there may be better ways than session variables for tracking if a user is logged in

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Heey, In my iPad application I have a UIPopoverController with a UIViewController containing some
Heey I want to make a netservice where more ipads can connect to at
Heey, I can localize my iPhone app with the systems local by localizing the
Heey, Does anybody know how to start safari from a ipad application? I wan't
<!DOCTYPE html> <html> <head> <title>Title</title> <meta http-equiv=content-type content=text/html; charset=utf-8> <style type=text/css> body { background:
I create select element dynamically using jquery, and I want to make action when

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.