By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Session Variable Length

P: n/a
Does anybody no the max length of data a session variable can contain ?
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I don't believe there are any size of length restrictions. Of course, if you
have lot's of users, and you are storing large objects in session, you need
to consider how much memory you have at your disposal.

"BobTheHacker" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Does anybody no the max length of data a session variable can contain ?

Nov 18 '05 #2

P: n/a
FWIW - I've been storing about 2000 chars in one of mine on a certain page
and no problems so far.


"BobTheHacker" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Does anybody no the max length of data a session variable can contain ?

Nov 18 '05 #3

P: n/a
length restrictions do not apply to the ASP.NET intrinsic objects like
session because they holds references. The limitation, as Marina pointed
out, is available memory on the machine.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:OX**************@tk2msftngp13.phx.gbl...
FWIW - I've been storing about 2000 chars in one of mine on a certain page
and no problems so far.


"BobTheHacker" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Does anybody no the max length of data a session variable can contain ?


Nov 18 '05 #4

P: n/a
We blew one the other day that was over 4,000 charcters. I thought I read somewhere that they were limited to 4kb. But I would like to confirm that.
Nov 18 '05 #5

P: n/a
Nope. Here's the proof of concept.

namespace WebApplication2
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Text.StringBuilder str = new System.Text.StringBuilder();
for (int i = 1; i < 2000000; i++)
str.Append(i.ToString()).Append(",");

Session["Test"] = str.ToString();
TextBox1.Text = Session["Test"].ToString();
}
}

The size of the cache is only capped by memory. I have cached datasets as
large as 167 megs.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"BobTheHacker" <an*******@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
We blew one the other day that was over 4,000 charcters. I thought I read
somewhere that they were limited to 4kb. But I would like to confirm
that.

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.