you can replace res with HttpContext.Current.Response in createCookie method
HttpContext.Current.Response.Cookies.Add(c);
OR
you can add new HttpResponse parameter to the method and pass it to the method as parameter
public void createCookie(string cookieName, string[] keys, string[] values, bool expired, HttpResponse res)
{
HttpCookie c = new HttpCookie(cookieName);
if (keys != null)
{
for (int x = 0; x < keys.Length; x++)
c.Values.Add(keys[x], values[x]);
if (!expired)
c.Expires = DateTime.Now.AddYears(5);
}
else
c.Expires = DateTime.Now.AddYears(-5);
res.Cookies.Add(c);
}