Passing variables vs session variable

what is the advantage of passing the variable in the url vs storing the variable in a session variable and retrieving it in the second webpage you are accessing?

10/2/2007 8:09:30 PM 91979 articles. 4 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 33

 The variable that you will pass using the QueryString will be visible to the user hence not secured. The value that you put in the Session is not available to the user as it is on the server side and hence more secured.

Wanna get high!
10/2/2007 8:13:35 PM

performance wise does it matter?

10/2/2007 8:22:16 PM

Just my 2 cents...

I remember in college the professors would always harp upon using the Session responsibly. Most of the professors were older and came from backgrounds where memory was used sparingly. So, if you were cramming loads of data into the Session (back in the day), you'd maybe begin to experience some bad effects because of it. Accordingly it was advised to use the Session sparingly.

However, it seems to me that things have changed a little. We have more memory and it's faster than ever; the average joe-blow user has more bandwidth than ever. Consequently I don't think people worry about using the Session too much as much.


This is the part where I politely request you to mark my response as the Answer, under the pretense that doing so will greatly help the community, blah, blah...
When in actuality I'm singlely intent upon the wopping 10 points that I'll receive!
... Oops, was that my outloud voice? ;)
10/2/2007 8:48:22 PM

Yes, performance wise, session variables take up memory on the server so using too many sessions can affect the overall performance of the site.  I use them a lot and haven't seen too much of a performance issue, you must have to use a lot of them to affect memory.  Or maybe sticking arrays into sessions would start to affect things.  Good luck, Mike

I wish there was only one way to do something!!
Need a transcription? -
10/2/2007 9:01:04 PM

there are a few ways of passing variables around:

 Single page Postbacks:

1) Use ViewState. It's simple, encrypted. Only problem is too much will slow the clients computer down

2) Use hidden <asp:labels />. Pretty much the same approach as the veiw state.

Navigating from page-> page

1) Query String. Yea, they might see some ID's at the top.

2) you can "Submit" to a new page with ASP.NET 2.0, which allows you to use values from your original page.

3) You can use session. But I would advise against it. Session variables should be used to house things that are important for the user, like: ID, UserName, etc. I would never want to see a dataTable, Array, etc. stored in the session.


The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

My Site | My Examples | My Blog

10/2/2007 10:27:36 PM

Similar Artilces:

Cache Variable vs. Session Variable
I'm anxious to get some feedback with regard to using a cache variable in lieu of a session variable. My research tells me that caching is the way to go for maintaining state on datasets. However, I've only seen the cache variable discussed as an alternative to an application variable (as opposed to the session variable). I'm actually exploring the idea using of using a cache variable as an alternative to a session variable for maintaining state on a dataset specific to each user (Each user is able to select the fields they wish to view; the user will then be able to page and sort on th...

Passing a variable to another page in a session variable
I want to pass a string to another page I'm opening with JavaScript using a session variable. The problem is, I might be opening 3 or 4 instances of this new window at the same time and I will need to pass a different value to each instance. Is there a good way to do this? well, the process you describe is off. there is no "passing", really, when using session state. once it's in there, it's in there across ALL page requests (even if that page request is opened through a javascript method). So it won't matter how many pages you access, or how many times, once it...

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

Can't get a new Session Variable to pass into a method (used Session, TextField and QueryString)
Hi Everyone,  I have been battling with this for about 18 hours now and coudl use some help...  I have a form that inserts into a DB table and then calls a method that makes a query to another table to create a Dataset for insert into a third table. ( I haven't done the third table insert yet but first things first.) Step 1 works fine. Step two is the problem. When I call the method I pass in two variables to get  return it will only work if I call an OLD Session variable. The session vaiable i set in the onSelectedChange event won't pass into the parameters... I als...

variable not a variable
Error:Must declare the variable '@cartDateTime'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@cartDateTime'. Dim connStr As SqlConnection            Dim cmdInsert As SqlCommand            Dim strInsert As String      &n...

variable of variables
Say I have 2 scenarios and I want to use a different variable depending on which scenario applies without coding this logic. So I could have a database table t_variables which has: Scenario: Variable: --------- -------- 1 v_name 2 v_company In my Powerbuilder code I'd have values in v_name & v_company. What I'd like to be able to do is to select which variable to use from the table and assign that to something, e.g. select variable into v_variable from t_variables where scenario = 1 so at this point v_variable would be 'v_name'...

variable variables?
Hello! How to make a variable receive an increment in the name? I want to do it for example: I have: Label1->Caption = "1"; Label2->Caption = "2"; Label3->Caption = "3"; Label4->Caption = "4"; And I want to do something like that: for (i=1; i<5; i++) { Label+i->Caption = i; } Any idea? Can I do something like that? Thanks and regards Alexandre Create a vector of pointers to the various objects. In your case below, construct a vector (called Labels) of pointers to TLable long enough to hold pointers to...

Variable Variables
Hi, Maybe the solution is very simple, but how do I create variable variables in I want to use the value of a variable as a part of the name of another variable. A very simple example below: code: Dim a As String a = "1" Label a.Text = "hi" page: <asp:Label id="Label1" runat="server">Label</asp:Label> In need this to change a range of values by using just one loop. I can´t do that without creating a variable variable name. Hi, check out this little demo application I created for you: ...

Passing a variable to a sub (WAS: passing a variable to a module)
This is really more of a question of how to pass a variable to a sub. First off, check out perldoc perlsub. To avoid problems like this, 'use strict' whenever possible at the top of your scripts. Anyway, here's how to fix this: Passing a variable to a sub: All variables passed to subs are put into the @_ array and then passed. Thus, when you do a printStatement($var), the contents of $var are passed to the first element of the @_ array. In the sub in your module, there is no such thing as the variable $var. If you had used 'use strict', you would have ge...

Response.Redirect with Session Variable vs. Global Variable -- Best Practices?
Hi,I have a simple contact form and when the user presses the submit button an email is sent and  I have a response.redirect to "emailSent.aspx" where it says "Your request has been received....etc.".  I have the submit button in a try/catch block.  What I want to do is a "emailFailed.aspx" where it says "Email problem, etc." but I also want to carry over the ex.message text.  I want to pass the ex.error text to the "emailFailed.aspx" page so on pageLoad I can have a label with something like:labelMessage.Text = "There was a problem with your email.  The error is " +...

How to pass variables within pages without showing it in URL and not using session variables
My aspx page need to be called from within another page. My page must receive 2 values (variables) form the page that will request may page, and  must hide these values (it can not appear in the URL). It seems that I must use  the get/post method, but Idont know how. Can someone show me a example with 2 small pages showing how one page can request another passing values (not showed in the URL)     tanks in advance   Take a look at this...

shared variable or session variable???
I've asked this question on a couple of different forums and usenet and noone has offered a reply, so I thought I'd try it here... I have 2 different web apps that happen to do almost exactly the same things. One I did many months ago and the other is very recent. In both cases, I had data that needed to be available throughout all the functions of the page. Looking at the code, I noticed that in the older one I used a shared variable (woud be static in c#) to hold the needed data. In the newer app, I simply used a session variable. The data itself is a dataTable. My question is:...

Session Variables Vs Session Class
Hi All, I am rewriting a classic ASP application in .NET using and C#. We used Session Variables to handle storing the current user information throughout the original application.  I was wondering what the benefits would be of using a Session Class over Session Variables, and also how I could implement this? Many thanks in advance for any information you can give me. Regards, Aj Check this out. I think Session class always beneficial since you have more control over accessing and setting your session variables and exception handling. Check the link for its sample implem...

Session variables vs. Session States
What is the difference and in what situations are they used. Thanks, Mattypee A session state (the state of your session) holds your session variables. If your session state expires (due to inactivity) then you lose your session variables...and any other info stored for that session. If you need to store USER specific information within a web app, then session variables are one(of several) ways to do it. MajorCatsMajorCats Is there any code that you could show that would give an example? Thanks, Mattypee example of what? reading and writing session variables? ...

Web resources about - Passing variables vs session variable -

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Cisco Debuts Open Pay Variable Pricing, Updates CCRE
Cisco Debuts Open Pay Variable Pricing, Updates CCRE Channel Partners Kris Snow, president of Cisco Capital, says the company's new Open Pay ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/3/2015 7:34:27 PM