Difference between Query string and Cookies

Posted by Krishnamanohar under ASP.NET on 1/30/2013 | Points: 10 | Views : 16410 | Status : [Member] | Replies : 5
Hi Guys,
can anyone please tel me the exact difference between Qurery string and Cookie.
which one is the best one to pass data?
in which senario we go for querystring and which senario we go for cookies.'
---------------------------------
Thanks in advace
Krish




Responses

Posted by: Shanky11 on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
cookies is a text file stored on client machine when we surf ant thing on internet by the server automatically we dont have to create it

query string is used to transfer data from 1 page to anothe but this is not safe s it shows in url what data we r sending
pen any site and see url after question mark tht is url
if u understood then mark this as correct ans if don't tell me what r u nt understanding ???????????????????

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kusumas on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
http://www.wiseowl.co.uk/blog/s319/asp-net-state.htm


Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Umar on: 1/31/2013 [Member] Starter | Points: 25

Up
0
Down
Query String

Query string is the limited way to pass information to the web server while Transferring from one page to another page. This information is passed in url of the request. see below the code sample


Code Sample

//Retrieving values from query string
String name;
//Retrieving from query string
name = Request.Param["umar"].ToString();

But remember that many browsers impose a limit of 255 characters in query strings. You need to use HTTP-Get method to post a page to server otherwise query string values will not be available.

Cookies

A cookie is a small amount of data which is either stored at client side in text file or in memory of the client browser session. Cookies are always sent with the request to the web server and information can be retrieved from the cookies at the web server.Cookies can be permanent in nature or temporary. ASP.Net internally stores temporary cookie at the client side for storing session identifier. By default cookies are temporary and permanent cookie can be placed by setting "Expires" property of the cookie object.

Regards,


Umar Deen

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 1/31/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Nice explanation satyapriyanayak

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Itishree on: 2/19/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Cookies:

Cookies are useful for storing less data of frequently changed information on the client. When server wants the information Cookie keeps tracking of information.
-Cookie can expire when the browser session ends, or it can exist indefinitely on the client computer, It depends on the assigned expiration time of Cookies.
-No server resources are required.
-We can send secure data by encryption and decryption but need more coding.
-Simplicity The cookie is a lightweight, text-based structure with simple key-value pairs.
-Cookies are browser dependent, thereby limiting this functionality.
-Size limitations most browsers place a 4096-byte limit on the size of a cookie, but for few browsers support for 8192-byte.

Query Strings:
-A query string is information that is passed through the URL of a page.Query string can be used to submit data back to your page or to another page through the URL.
-No server resources are required the query string is contained in the HTTP request for a specific URL.
-Less code and easy way to pass information to different pages but not secured.
-Almost all browsers and client devices support using query strings to pass values.
-ASP.NET provides full support for the query-string method.
- Limitation for the length of browser URL is 2083-character limit.


Regards,
Itishree

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response