I have read many SO questions about the session issues within iframe but it doesn't seem to be the exact answer for the problem I'm having.
I have a php site which displays my .aspx sites within iframe.
In Default.aspx
, I get data passed from the parent (php) site and store it in a session variable as follows:
var c = HttpContext.Current;
string name1 = c.Request.Form["FirstName"];
string name2 = "Nancy";
Session["name1"] = name1;
Session["name2"] = name2;
lblTest1.Text = "name1 = " + Session["name1"];
lblTest2.Text = "name2 = " + Session["name2"];
the print result is:
name1 = John
name2 = Nancy
The problem is, Session["name1"] loses its value but Sessoin["name2"] still holds its value after postback.
I try to print both names in the next page like this:
lblTest1.Text = "name1 = " + Session["name1"];
lblTest2.Text = "name2 = " + Session["name2"];
and the result is:
name1 = //blank
name2 = Nancy
I tried adding this in Session_Start
if (Request.IsSecureConnection)
{
Response.Cookies["ASP.NET_SessionID"].Secure = true;
}
and also tried Session Variables not saved when page is in an iFrame, but this problem occurs in any browsers (IE, FF, Chrome).
The value of name1 comes from the parent site but is it that storing it in a session doesn't work?