Alright, so. For some reason, this cookie is getting deleted/overwritten.
It does exists for awhile. well, for one cycle of Code 2, but when code 2 is called again VIA a page load, it doesnt contain my data.
What the cookie contains is a encoded session ID which is used to determine who that user is and if they are an Admin or not.
and if it doesnt have the sessionID to use to compare, it directs the user to the login page.
Assume the User Role is set to 1.
Code 1: http://pastebin.com/rfP7se0x
Code 2: http://pastebin.com/c2Jy7zQ1 (stripped allot of code not pertaining to cookies.)
Code 3:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FormsAuthenticateProject.Customer
{
public partial class Customer : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DBConnLayer DBCL = new DBConnLayer();
DBCL.userRoleRedirect();
}
}
}
}
This answer has already been answered here: cookie values disappear when traversing between content pages
I added this code into the first line of userRoleRedirect
if (Request.Cookies["Session"] != null)
{
Response.Cookies.Set(Request.Cookies["Session"]);
}
and HttpCookie myCookie = Request.Cookies["Session"];
to
var myCookie = Request.Cookies["Session"].Values;
I fetch values using myCookie["ValueName"]
It returns a string.