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();
}
}
}