473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

which one is better - Using cookies or session objects?

304 100+
Hi,
I would like to know as to which method is better?
Using session objects or cookies for storing information?
Which one would be more reliable?
And will there be any visible differences in the speed of the website when one option is chosen over the other?

Thanks,
Gomzi.
May 30 '07 #1
10 2026
Plater
7,872 Expert 4TB
A Session is a special kind of cookie with different expiration rules.

It basicly sets a cookie for your webdomain with something like COOKIE@mydomain {SESSION: <long unique string>}
And your webserver has a sort of database in memory that maps that long unique string to a collection of data objects (which you would access with the Session["object_name"] call)

Sessions can build up and occupy a lot of memory on the server, but it (slightly) speeds up data-transfer since you aren't passing in the header all the cookies you would use.
i.e.
COOKIE1@mydomain {mycolor: <value>}
COOKIE2@mydomain {myname: <value>}
COOKIE3@mydomain {myaddress: <value>}
COOKIE4@mydomain {myphonenumber: <value>}

Now, a session cookie is only good as long as your webserver maintains a session record for it in it's DB (which gets reset on rebuilds and timeouts and the like), while a standard cookie could potentially stay as long as you want it to (unles a user deletes it manually)
May 30 '07 #2
Frinavale
9,735 Expert Mod 8TB
Hi Gomzi,

Check out this .NET article on Sessions to help you understand them a bit better.

As for your question: Cookies vs Session Objects.

It really depends on the information that you're system's going to be using. Cookies are stored on the client side. This means that you're depending on the user's computer to hold information. It also means that there is a greater possibility this information can be modified by the user, or captured by a 3rd party and used in a malicious manner.

Sessions depend on a Session Identifier Cookie to identify the browser with their Session objects. So, either way you're still going to have to use at least one cookie.

I myself tend to use Sessions mostly, but this is just a matter of preference.

-Frinny
May 30 '07 #3
TRScheel
638 Expert 512MB
Hi Gomzi,

Check out this .NET article on Sessions to help you understand them a bit better.

As for your question: Cookies vs Session Objects.

It really depends on the information that you're system's going to be using. Cookies are stored on the client side. This means that you're depending on the user's computer to hold information. It also means that there is a greater possibility this information can be modified by the user, or captured by a 3rd party and used in a malicious manner.

Sessions depend on a Session Identifier Cookie to identify the browser with their Session objects. So, either way you're still going to have to use at least one cookie.

I myself tend to use Sessions mostly, but this is just a matter of preference.

-Frinny
Slightly out of the norm... but... its appropriate...

<3 Sessions


If you havent seen the danger in cookies, go to Hack This Site
May 30 '07 #4
Frinavale
9,735 Expert Mod 8TB
Slightly out of the norm... but... its appropriate...

<3 Sessions


If you havent seen the danger in cookies, go to Hack This Site
Awesome!
In the back of my mind I was looking for a site like this one. Thanks a lot for the link TRScheel!
May 30 '07 #5
gomzi
304 100+
Hi Gomzi,

Check out this .NET article on Sessions to help you understand them a bit better.

As for your question: Cookies vs Session Objects.

It really depends on the information that you're system's going to be using. Cookies are stored on the client side. This means that you're depending on the user's computer to hold information. It also means that there is a greater possibility this information can be modified by the user, or captured by a 3rd party and used in a malicious manner.

Sessions depend on a Session Identifier Cookie to identify the browser with their Session objects. So, either way you're still going to have to use at least one cookie.

I myself tend to use Sessions mostly, but this is just a matter of preference.

-Frinny
I see. Thanks mate. Just read your article too. Could you tell me as to what exactly you mean by "web garden"?

Thanks,
Gomzi.
May 30 '07 #6
TRScheel
638 Expert 512MB
I see. Thanks mate. Just read your article too. Could you tell me as to what exactly you mean by "web garden"?

Thanks,
Gomzi.
A web garden is a site that is hosted with multiple processes.

NOT to be confused with a web farm, which is a site hosted on multiple servers.
May 30 '07 #7
Hi,
I would like to know as to which method is better?
Using session objects or cookies for storing information?
Which one would be more reliable?
And will there be any visible differences in the speed of the website when one option is chosen over the other?

Thanks,
Gomzi.
session method is better to storing information rather than cookies...
session varible is more relaible compare to cookies
May 31 '07 #8
it actually depends on the situtation on which u r working sometime cookies are mush better option then session and some time session is better.
May 31 '07 #9
Plater
7,872 Expert 4TB
Since we're still discussing I will weigh in on how I use them.
I have one section of a website with a custom login, I use a session object to store login credentials and user info (i.e. I pull like their NAME and other stuff into the session so I can use them on all the pages)
Since I don't care about the information outside of the session, it can expire with the session.

Now I also have an order form (outside of the login area) with lots of fields to fill out. On a successful submition, I give the user the ability to save a cookie retaining a number of the fields as a cookie. So everytime they go back to the form, things like email and name and other bits of information are kept for them and already filled in.
May 31 '07 #10
gomzi
304 100+
Since we're still discussing I will weigh in on how I use them.
I have one section of a website with a custom login, I use a session object to store login credentials and user info (i.e. I pull like their NAME and other stuff into the session so I can use them on all the pages)
Since I don't care about the information outside of the session, it can expire with the session.

Now I also have an order form (outside of the login area) with lots of fields to fill out. On a successful submition, I give the user the ability to save a cookie retaining a number of the fields as a cookie. So everytime they go back to the form, things like email and name and other bits of information are kept for them and already filled in.
Hm......... I seem to be getting your point. But if one has a site hosted on a shared hosting environment, then which one would you prefer?
OR
It makes no difference?

Thanks,
Gomzi.
May 31 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
5
by: Hung Huynh | last post by:
Hello, I have 2 separate web sites on 2 different boxes www.xyz.com on box 1 www2.xyz.com on box 2 Users log into box 1 via regular ASP/Database authentication, and I keep a session...
3
by: Mooky Mooksgill | last post by:
I'm writing a reporting application in ASP. I want to have links to a CF app - specifically VeriSign's eCommerce Manager (on VeriSign's server). The links in my app will need current values...
2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
2
by: Logician | last post by:
Objective To build a site which works with ALL client systems, eg firewalls, disabled cookies, etc Current Site Works with HTTP cookies and when I try and convert to Session Ids and...
4
by: Thomas Eichner | last post by:
Hi, does anybody know a public website which offers a service that displays all data send by a browser (or an app calling the website), especially HTTP GET and POST data, browser data etc.? I...
9
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a...
24
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How can I see in javascript if a web browser accepts cookies?...
3
by: sanchita | last post by:
Hello everyone, I didn't get any response in "Security" forum hence posting here again. I am having problem with persistent cookies. Even after setting "CreatePersistentCookie" to true in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.