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

  • Home
  • SEARCH
  • 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 8875621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:01:08+00:00 2026-06-14T19:01:08+00:00

error is: The name ‘Response’ does not exist in the current context when i

  • 0

error is: The name ‘Response’ does not exist in the current context when i try to use Response.Cookies.Add(cookie);

I’m not sure what else should I need to include to get it work.
I making app where user can login and when they login cookie is made so they dont need to login again when they reopen the app .

using MySql.Data.MySqlClient;
using System.Web;




namespace login
{

    public partial class Form1 : Form
    {
        MySqlConnection konekcija;
        string baza = "host=localhost;database=test;user=root;password=";
        MySqlCommand comm;
        MySqlDataReader reader;
        HttpCookie cookie;




        public Form1()
        {
            InitializeComponent();
        }



        private void Form1_Load(object sender, EventArgs e)
        {
            konekcija = new MySqlConnection(baza);
            comm = konekcija.CreateCommand();
            konekcija.Open();


        }



        private void button1_Click(object sender, EventArgs e)
        {

            string user = textBox2.Text.ToString();
            string pass = textBox1.Text.ToString();
            trylogin( user,  pass);

        }

        public void trylogin(string user, string pass)
        {

            if (checkBox1.Checked)
            {
                cookie = new HttpCookie("remember_me");
                cookie["Username"] = textBox2.Text;
                cookie["Expire"] = "365 Days";
                cookie.Expires = DateTime.Now.AddDays(365);
                Response.Cookies.Add(cookie);


            }

            comm.CommandText = "SELECT * FROM korisnici WHERE user='"+user+"' AND pass='"+pass+"'";

            reader = comm.ExecuteReader();
            if (reader.Read() == true)
            {

                reader.Dispose();
            }
            else 
            {
                reader.Dispose();
            }

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            konekcija.Close();
        }
    }
}
  • 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-06-14T19:01:09+00:00Added an answer on June 14, 2026 at 7:01 pm

    Search the web for “remember me in c#”, you’ll find many discussions, i.e.:

    "Remember Me" in ASP.Net

    http://forums.asp.net/t/1303629.aspx

    Anyway, you’re attempting something really insecure with your code, watch out.


    Regardless your “remember me” task, ok, you may want to compose your sql queries “on the fly”, just remember to double your quotes with a replace before sending to sql engine:

    user = user.Replace("'", "''"); //Assuming string values are not null here
    password = password .Replace("'", "''");
    comm.CommandText = "SELECT * FROM korisnici WHERE user='"+ user +"' AND pass='"+ password +"'";
    

    I strongly encourage you learn using parameters (i.e. “… and user=@user”): they will give you more security and robustness to your code and doing so you don’t need to use Replaces.

    Another good practice is to extract only needed fields. If anyone gets access to this result someway and you have also put password field in clear text, this will happly shows it out.
    If you don’t “select *”, system maybe still unsecure, but at least you don’t give anything out for free:

    comm.CommandText = "SELECT user_name,login_level,anything_you_really_need FROM korisnici WHERE user=@user AND pass=@pass";
    MySqlParameter pUser = new MySqlParameter("@user", user);
    MySqlParameter pPass = new MySqlParameter("@pass", password);
    
    comm.SelectCommand.Parameters.Add(pUser);
    comm.SelectCommand.Parameters.Add(pPass);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi every one I am getting the following error: The name 'ConfigurationManager' does not
Im receiving the following error Name 'Encryption' is not declared. On Line If reader_login(password).ToString()
I'm getting an error: name 'i' is not defined k = [ [ rids[i][j][0]['a']
I've this class and it gave me an error name 'ScriptManager is not declared'
I get the error error: ‘Name’ was not declared in this scope What am
Im getting a name error: name sitemaps is not defined from my urls.py when
I have a function that checks if a cookie (by name) exists or not:
Instead of showing an error message 'Name is required' I would like to change
It's giving the UNKNOWN TYPE NAME error. I had imported billSummary class as well,
i get this error when trying this: ERROR method name expected. How should i

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.