ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is the difference between cookies and session?
 Question Submitted By :: Kayalvizhy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between cookies and session?
Answer
# 1
State Management in APS.NET is managed by two ways:
Client-Side or Server-Side

Client-Side:Cookies,HiddenFields,ViewState and Query 
Strings.
Serve-Side:Application,Session and Database.

COOKIE:
A cookie is a small amount of data stored either in a text 
file on the client's file system or in-memory in the client 
browser session. Cookies are mainly used for tracking data 
settings. Let’s take an example: say we want to customize a 
welcome web page, when the user request the default web 
page, the application first to detect if the user has 
logined before, we can retrieve the user informatin from 
cookies:
[c#]
if (Request.Cookies[“username”]!=null)
lbMessage.text=”Dear “+Request.Cookies[“username”].Value+”, 
Welcome shopping here!”;
else
lbMessage.text=”Welcome shopping here!”;

If you want to store client’s information, you can use the 
following code:
[c#]
Response.Cookies[“username’].Value=username;

So next time when the user request the web page, you can 
easily recongnize the user again.

SESSION:
Session object can be used for storing session-specific 
information that needs to be maintained between server 
round trips and between requests for pages. Session object 
is per-client basis, which means different clients generate 
different session object.The ideal data to store in session-
state variables is short-lived, sensitive data that is 
specific to an individual session.

Each active ASP.NET session is identified and tracked using 
a 120-bit SessionID string containing URL-legal ASCII 
characters. SessionID values are generated using an 
algorithm that guarantees uniqueness so that sessions do 
not collide, and SessionID’s randomness makes it harder to 
guess the session ID of an existing session.
SessionIDs are communicated across client-server requests 
either by an HTTP cookie or a modified URL, depending on 
how you set the application's configuration settings.

Every web application must have a configuration file named 
web.config, it is a XML-Based file, there is a section 
name ‘sessionState’, the following is an example:

<sessionState mode="InProc" 
stateConnectionString="tcpip=127.0.0.1:42424" 
sqlConnectionString="data source=127.0.0.1;user 
id=sa;password=" cookieless="false" timeout="20" />

‘cookieless’ option can be ‘true’ or ‘false’. When it 
is ‘false’(default value), ASP.NET will use HTTP cookie to 
identify users. When it is ‘true’, ASP.NET will randomly 
generate a unique number and put it just right ahead of the 
requested file, this number is used to identify users
[c#]
//to store information
Session[“myname”]=”Mike”;
//to retrieve information
myname=Session[“myname”];

this is briefly about cookies and sessions in ASP.NET
 
Is This Answer Correct ?    13 Yes 2 No
Kishoreg
 
  Re: What is the difference between cookies and session?
Answer
# 2
Cookies
1.	Cookies can store only "string" datatype 
2.	They are stored at Client side 
3.	Cookie is non-secure since stored in text format at 
client side 
4.	Cookies may or may not be individual for every 
client 
5.	Due to cookies network traffic will increase.Size 
of cookie is limited to 40 and number of cookies to be used 
is restricted to 20. 
6.	Only in few situations we can use cookies because 
of no security 
7.	We can disable cookies 
8.	Since the value is string there is no security 
9.	We have persistent and non-persistent cookies

Session
1.	Session can store any type of data because the 
value is of datatype of "object" 
2.	These are stored at Server side 
3.	Session are secure because it is stored in binary 
format/encrypted form and it gets decrypted at server 
4.	Session is independent for every client i.e 
individual for every client 
5.	There is no limitation on size or number of 
sessions to be used in an application 
6.	For all conditions/situations we can use sessions 
7.	we cannot disable the sessions.Sessions can be used 
without cookies also(by disabling cookies)
8.	The disadvantage of session is that it is a 
burden/overhead on server 
9.	Sessions are called as Non-Persistent cookies 
because its life time can be set manually
 
Is This Answer Correct ?    1 Yes 0 No
Aruna Jyothi
 
 
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
why sturcture ? why class?why you prefer structure and in which cases u go for class? Microsoft1
What is covariance and contravariance? Did Delegate and method overriding support these? TCS1
Method1() { int a=0, b=0, c=0; Monitor.Enter(this) c = 12; b = 3; a = c/b Moniter.Exit(this) } Method1() { int a=0, b=0, c=0; c = 12; b = 3; lock(this){ a = c/b } } Choose correct answer. a. Upon completion, Method1 and Method2 release the lock b. Upon Comletion, Method1 release the lcok and Method2 not. c. Upon Completion, Method2 release the lock and Method1 not. d. Upon Completion, neither Method1 or Method to release the lock.  1
What?s the difference between the Debug class and Trace class?  2
what is a constructor? Choice-Solutions4
Explain manifest & metadata? Wipro5
What?s a satellite assembly?  2
I am using a data table and a datagridview. I am creating two columns in data grid view : 1)DataGridViewComboBoxColumn 2)DataGridViewTextBoxColumn. The items of datagridviewcombo are the list of all items in data table column 1. I want that the data type of the DataGridViewTextBoxColumn should be the same as the data type of the item selected from the datagridviewcombo at runtime. How can I do that.Also I want that each cell in column of datatable should be of variable data type. Pls help. thnx. Storm1
What does assert() do?  1
What is the Difference between directcast and ctype? Wipro1
What?s the difference between System.String and System.StringBuilder classes?  1
how do you do exception management Accenture1
What?s a delegate? Visual-Soft6
Explain About the Sattilite Assembly in .Net Technology? TCS2
Indexers in c#? Microsoft7
How do you implement Inheritance in dot net ? MMTS3
what are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?  1
f i give input like 1,1,4,5,6,1,2,5,4,1,2, then output should be like : 1-4, 2-2, 4-2, 5-1, 6-1 which means 1 occurs 4 times, 2 occurs 2 times like so.  5
what is a callback function?  4
How to print labels in windows form in C# .net  4
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com