I have written this code in asp.net c# that checks for a cookie called AIO , if found , if not found it will create it
then on another page i have an iframe that will call a page from another website , this page in the iframe will check if the cookie is available and create a session , and everything is working great as i want on my Local Server 2008.
but when i uplaod these pages to the Server 2008 online , and run the code the cookie is not created , as it is diplaying for me the login page , equal cookie was not found
below is the code , hope someone can help me
HttpCookie userCookie;
userCookie = Request.Cookies["AIO"];
if (userCookie == null)
{
userCookie = new HttpCookie("AIO");
Response.Cookies.Add(userCookie);
}
and on the other page that should be displayed in the Iframe
If Request.Cookies("AIO") Is Nothing Then
Response.Redirect("LoginPage.aspx")
Else
Session("IsAuthenticated") = True
End If
If Session("IsAuthenticated") Is Nothing OrElse Convert.ToBoolean(Session("IsAuthenticated")) = False Then
Response.Redirect("LoginPage.aspx", True)
End If
userCookie = Request.Cookies["AIO"]; "
U were actually creating a cookie.
Instead, Check for cookie availabilty like this.
"Response.Cookies.AllKeys.Contains("test");
Refer BrokeAllen link. its explains clearly what i said above.
senior_oracl...
Member
30 Points
163 Posts
Cookie not being created !!???
Jan 16, 2013 12:53 PM|LINK
I have written this code in asp.net c# that checks for a cookie called AIO , if found , if not found it will create it
then on another page i have an iframe that will call a page from another website , this page in the iframe will check if the cookie is available and create a session , and everything is working great as i want on my Local Server 2008.
but when i uplaod these pages to the Server 2008 online , and run the code the cookie is not created , as it is diplaying for me the login page , equal cookie was not found
below is the code , hope someone can help me
HttpCookie userCookie; userCookie = Request.Cookies["AIO"]; if (userCookie == null) { userCookie = new HttpCookie("AIO"); Response.Cookies.Add(userCookie); }and on the other page that should be displayed in the Iframe
If Request.Cookies("AIO") Is Nothing Then Response.Redirect("LoginPage.aspx") Else Session("IsAuthenticated") = True End If If Session("IsAuthenticated") Is Nothing OrElse Convert.ToBoolean(Session("IsAuthenticated")) = False Then Response.Redirect("LoginPage.aspx", True) End IfHelp please !!!
BrockAllen
All-Star
27544 Points
4907 Posts
MVP
Re: Cookie not being created !!???
Jan 16, 2013 11:38 PM|LINK
Perhaps this is your issue?
http://brockallen.com/2012/09/04/beware-accessing-response-cookies/
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
mani2009it
Member
207 Points
82 Posts
Re: Cookie not being created !!???
Jan 17, 2013 04:00 AM|LINK
By writing this line,
userCookie = Request.Cookies["AIO"]; " U were actually creating a cookie. Instead, Check for cookie availabilty like this. "Response.Cookies.AllKeys.Contains("test"); Refer BrokeAllen link. its explains clearly what i said above.