Session contents lost despite Session.Timeout = 3000; and <sessionState mode="InProc" cookieless="f

  • Thread starter Thread starter Carpe Diem
  • Start date Start date
C

Carpe Diem

Hello I have an aspx page that loses Session("user") value after a few
minutes even after I set
<sessionState mode="InProc" cookieless="false" timeout="300"> in web.config
and wrote
function Session_Start() {
Session.Timeout = 3000;
}

in global.asax

Can you give me pointers on how to achieve the required functionality?
 
hi,
that is not possible ..
and no need to specify timeout to be 300.
just 10 or 20 will do...

try to find the exact reason why sessio is not mantained..

plz send some snippet of code...
 
I had a problem with session variables disappearing within one minute of
being created at sites hosted by one web host. I got them to increase the
Virtual memory limit on their application pools. That reduced recycling and
increased session durations.
 
some code::
list.aspx:: (this is the page that timeouts early)
<%@ Page Language="JScript" debug='true' Strict="true" Explicit="true"
Trace="false" enableSessionState="true" EnableViewState="true" Buffer="true"
%>
<script runat='server'>
var user : String;

function Page_Load(src : Object, e : EventArgs) {
user = String(Session("loggedIn"));
if (user == null || user == "null" || user == "" || user == "undefined") {
Response.Redirect("mailing_login.aspx?authorised=no");
Response.End();
}
//some data display
}
</script>
<form runat='server'>
<%=mailingListName%> subscribers:<br />
<br />
<span id="subscribersMsg" runat='server' /><br />
<asp:DataList id='subscribers' runat='server'>
<ItemTemplate>
<a href='deleteSubscriber.aspx?subscriberId=<%#
Int32(Container.DataItem("SubscriberID"))
%>&amp;mailingListId=<%=mailingListID%>' onClick='return(confirm("Are you
sure you want to delete subscriber <%#
String(Container.DataItem("SubscriberEmail")) %> (no undo
possible)?"));'>delete</a>
<%# String(Container.DataItem("SubscriberEmail")) %><br />
</ItemTemplate>
</asp:DataList>
</form>
<input type='button' value='add subscriber' runat='server'>

----------------------------------------------------------------------------
---------------------------------------------------------

mailing_login.aspx:: (login page)
<%@ Page Language="JScript" debug='false' Strict="true" Explicit="true"
Trace="false" EnableSessionState="true" EnableViewState="false"
Buffer="true" %>

<HTML>
<head>
<script language='JScript' runat='server'>
function Page_Load() {
if (Request.QueryString("authorised") != null) {
Msg.Text = "You must login to access this site.<br />"
}
}
function LoginBtn_Click(sender : Object, e : EventArgs) {
//get user from database

if (userFound) {
Session("loggedIn") = UserName.Text;
Response.Redirect("default.aspx");
} else {
Msg.Text += "Invalid Credentials: Please try again.<br />";
}
}
</script>
<form runat="server">
<h2>Mailing List :: Login Page</h2>
<hr size="1" />
<table>
<tr>
<td>Username:</td>
<td><asp:TextBox id="UserName" runat="server" /></td>
<td><asp:RequiredFieldValidator id="userRequired" runat="server"
ControlToValidate="UserName" Display="Static" ErrorMessage="Missing!"
/></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox id="UserPass" runat="server" TextMode="Password"
/></td>
<td><asp:RequiredFieldValidator id="passRequired" runat="server"
ControlToValidate="UserPass" Display="Static" ErrorMessage="Missing!"
/></td>
</tr>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login" />
<p><asp:Label id="Msg" runat="server" ForeColor="red" /></p>
</form>

</head>
<body>
</body>
</HTML>
 
Back
Top