Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Session Variable vs Cookie

Reply
Thread Tools

Session Variable vs Cookie

 
 
Wayne Wengert
Guest
Posts: n/a
 
      05-20-2004
Are Session variables the same as a cookie? In reading a couple of pages I
got from searches, I don't get the difference. Basically, I am currently
using simple session variables (e.g. Session("UserName") =
txtLastName.Text). I think they are expiring for some users (longer
sessions?) and I need to be able to set the expiration to something like
Now() plus 2 hours.

What is the right way to do this?

Wayne


 
Reply With Quote
 
 
 
 
Ketchup Please
Guest
Posts: n/a
 
      05-20-2004
Nope: Session and cookies are not the same thing. A cookie is a text file
that lives on the user's computer. Session is typically the Web server's
memory and exists for 20 minutes by default. Session can be a lot more than
that, though. You can accomplish what you need to in a variety of ways, but
it might be easiest for you to go with cookies. Read up in the online help
on cookies - how to create them, set expiration time, etc...

K


"Wayne Wengert" <> wrote in message
news:ee$...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
>
> What is the right way to do this?
>
> Wayne
>
>



 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      05-20-2004
Sessions are not really cookies. Basically, session variables are kept in
memory on the server (or through another method such as a database). They
set a cookie on the browser with information to identify exactly what
session the browser is part of. Sessions are usually kept short so that the
server can then close them out and release their resources frequently. That
way, you don't end up with hundrends of sessions active that actually don't
have any users doing anything (sessions don't close when someone browses to
another web site). For things like login information, shorter sessions are
good because if a user leaves their computer and someone else walks up, the
window of opportunity for such an error is reduced. You may want to see what
is useful to put into cookies if you need to keep good control over the time
a value is stored for without eating up tons of server resources. You may
also want to look at ASP.Net's forms authentication features as it also has
a sliding expiration for user information. In other word, the timeout is
refreshed whenever the user grabs another page on the site.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Wayne Wengert" <> wrote in message
news:ee$...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
>
> What is the right way to do this?
>
> Wayne
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
session cookie and presist cookie? =?Utf-8?B?amVycnkueHVkZGQ=?= ASP .Net 1 03-07-2006 11:16 PM
Cookie and Session Cookie Questions. Shapper ASP .Net 1 04-27-2005 11:20 AM
Session cookie? Browser instance cookie? Ben ASP .Net 3 06-03-2004 03:41 AM
session cookie vs. regular cookie Matt ASP General 1 01-25-2004 05:09 AM
authentication cookie vs session cookie Joseph ASP .Net Security 4 08-12-2003 10:57 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57