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

Parameters VS Session Values

P: n/a
When redirecting a page,

For example

CASE 1;

Response.Redirect("Page.aspx?Paramval=123");

in Page.aspx

string aaa = GetQueryString("Paramval")

CASE 2;

Session("Paramval") = 123
Response.Redirect("Page.aspx");

in Page.aspx

string aaa = Session("Paramval");

Which one is better?

Thanks
Oct 2 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
CASE 1;
>
Response.Redirect("Page.aspx?Paramval=123");

in Page.aspx

string aaa = GetQueryString("Paramval")
Pro: This does not require cookies and can be linked to from other sites
Con: The url can be changed by the user and you can't control it
CASE 2;

Session("Paramval") = 123
Response.Redirect("Page.aspx");

in Page.aspx

string aaa = Session("Paramval");
Pro: You control what is in the session, the user can't alter it
Con: The page can't be linked to from another site, requires cookies, and if
I sit idle at Page.aspx such that my session times out and I refresh then
the Session variable has gone. Also this requires server-side storage for
each active user.

So neither is "better", it depends what you want.
Oct 2 '07 #2

P: n/a

Is there a relation between Session Variables and cookies ?

My purpose is to pass a datarow id to page.aspx and place this is in a
hidded field, so it wont be erased

But what is the relation between cookies and session values?

is there an alternative way of using session vals? Everyone uses them and if
cookiless system ?
"Aidy" <ai**@xxnoemailxx.com>, iletide şunu yazdı
news:AY******************************@bt.com...
>CASE 1;

Response.Redirect("Page.aspx?Paramval=123");

in Page.aspx

string aaa = GetQueryString("Paramval")

Pro: This does not require cookies and can be linked to from other sites
Con: The url can be changed by the user and you can't control it
>CASE 2;

Session("Paramval") = 123
Response.Redirect("Page.aspx");

in Page.aspx

string aaa = Session("Paramval");

Pro: You control what is in the session, the user can't alter it
Con: The page can't be linked to from another site, requires cookies, and
if I sit idle at Page.aspx such that my session times out and I refresh
then the Session variable has gone. Also this requires server-side
storage for each active user.

So neither is "better", it depends what you want.

Oct 2 '07 #3

P: n/a
When you first use a site a Session is created and the Session ID is stored
in a cookie. With each subsequent page request that cookie is given to the
site and your request is linked with your active Session. The actual
session values are all stored on the server, but the Session ID is stored in
a cookie. If you disable cookies then sessions won'r work and every page
will be like accessing the site for the first time.

Note that there is now a way to configure your site using cookieless
sessions where the session ID is automatically apended to each URL instead.

If you want to store values on the page that are passed back when the page
is submitted you could look at using the ViewState instead.

"Sylvie" <ss*@sss.sswrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
Is there a relation between Session Variables and cookies ?

My purpose is to pass a datarow id to page.aspx and place this is in a
hidded field, so it wont be erased

But what is the relation between cookies and session values?

is there an alternative way of using session vals? Everyone uses them and
if cookiless system ?
"Aidy" <ai**@xxnoemailxx.com>, iletide şunu yazdı
news:AY******************************@bt.com...
>>CASE 1;

Response.Redirect("Page.aspx?Paramval=123");

in Page.aspx

string aaa = GetQueryString("Paramval")

Pro: This does not require cookies and can be linked to from other sites
Con: The url can be changed by the user and you can't control it
>>CASE 2;

Session("Paramval") = 123
Response.Redirect("Page.aspx");

in Page.aspx

string aaa = Session("Paramval");

Pro: You control what is in the session, the user can't alter it
Con: The page can't be linked to from another site, requires cookies, and
if I sit idle at Page.aspx such that my session times out and I refresh
then the Session variable has gone. Also this requires server-side
storage for each active user.

So neither is "better", it depends what you want.


Oct 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.