Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Parameters VS Session Values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sylvie - 02 Oct 2007 12:31 GMT
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
Aidy - 02 Oct 2007 12:52 GMT
> CASE 1;
>
[quoted text clipped - 3 lines]
>
>    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;
>
[quoted text clipped - 4 lines]
>
>    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.
Sylvie - 02 Oct 2007 13:02 GMT
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 ?

>> CASE 1;
>>
[quoted text clipped - 23 lines]
>
> So neither is "better", it depends what you want.
Aidy - 02 Oct 2007 14:19 GMT
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.

> Is there a relation between Session Variables and cookies ?
>
[quoted text clipped - 33 lines]
>>
>> So neither is "better", it depends what you want.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.