protected void btnReserve_Click(object sender, EventArgs e) { DateTime startTime = Convert.ToDateTime(txtStartTime.Text); DateTime endTime = Convert.ToDateTime(txtEndTime.Text); int spot_ID = drpSpot.SelectedIndex; spot_ID++; // Reading cookies HttpCookie userName = Request.Cookies["USER_ID"]; string uid = userName != null?userName.Value.Split('=')[1] : "undefined"; ReservationData rd = new ReservationData(); int resId = rd.CreateNew(uid, spot_ID, startTime, endTime); MessageBox.Show("Your reservation has been sucessful. Reservation ID:" + resId); // write cookies HttpCookie res_ID_cookie = new HttpCookie("RES_ID"); res_ID_cookie["RES_ID"] = "" + resId; res_ID_cookie.Expires = DateTime.Now.AddHours(1); Response.Cookies.Add(res_ID_cookie); Response.Redirect("homePage.aspx"); }