On a Win 2KPro machine w/ IIS 5.0, I am building a test ASP.NET application with Delphi 8. It appears that my session variables are not persisting between page requests. However, the Session.SessionID remains the SAME. In other words, each time the page is loaded, the SessionID is the same, but the variables are gone.
My Delphi 8 example (below) sets a session variable "MyVar" which is subsequently lost when the page is reloaded. I originally thought my problem was in the code, but I suspect it lies in my IIS & ASP.NET configuration.
Could any post a link to a SIMPLE sample project that uses asp.net & session variables that I can load onto my IIS? This way I can be sure it is not Delphi related. Thanks.
Here what I've done, so far:
I set my IE browser to 'Accept All Cookies'. (It was set to 'Low').
I created a new ASP.NET application, using all default names. (WebApplication1,etc.)
I added 3 labels and 2 buttons to WebForm1.
Here is the code that I added:
procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
begin
Label1.Text := 'Session Id = '+Session.SessionID;
if Session['MyVar']<>nil then
Label2.Text := 'MyVar = '+Session['MyVar'].ToString
else
Label2.Text := 'MyVar is undefined.';
end;
procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
Session['MyVar'] := 'George Bush';
Label3.Text := 'MyVar set to '+ Session['MyVar'].ToString;
end;
procedure TWebForm1.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
Session['MyVar'] := 'John Kerry';
Label3.Text := 'MyVar set to '+ Session['MyVar'].ToString;
end;
--------------------
Here is the output:
First Display:
Session Id = bjhiwo2fgvpsgcrxxsxqk245
MyVar is undefined.
Label
After clicking Button1:
Session Id = bjhiwo2fgvpsgcrxxsxqk245
MyVar is undefined.
MyVar set to George Bush
After clicking Button2:
Session Id = bjhiwo2fgvpsgcrxxsxqk245
MyVar is undefined.
MyVar set to John Kerry