473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to determine if a Session Variable exists?

Hello,

How to determine if a Session Variable exists?

In Page_Load I need to check is Session("MyVar") Exists.
If it doesn't exist then I created it and give it a value:
Session("myVar") = "Value"

Thanks,
Miguel

Nov 19 '05 #1
3 2545
If variable doesn't exist then its null. Simlpy.

Ziemowit

Nov 19 '05 #2
Simply do this..

if ( Session("MyVar") == "" )
{
Session("MyVar") = "Your Value"
}

Nov 19 '05 #3
Ancient Zen problem:

If a Session variable is set, and there is no class to read it, does it
consume resources?

--
;-)

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:Oh*************@TK2MSFTNGP14.phx.gbl...
Hello,

How to determine if a Session Variable exists?

In Page_Load I need to check is Session("MyVar") Exists.
If it doesn't exist then I created it and give it a value:
Session("myVar") = "Value"

Thanks,
Miguel

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jeff | last post by:
I've searched the web for hours trying to figure out this problem and can't seem to find any pertinent answers. I have a website where the user starts on a login page, puts in their credentials and...
15
by: | last post by:
Hi, I want to do things this way: I have a bunch of stuff that I want to keep track of while a user is connected to the site. Maybe 50 little peices of information. So I know I can make 50...
4
by: Dean | last post by:
I finally got class session variables to work by putting the following in global.asax in the session_start: dim myDBComp as DBComp = new DBComp........ session("myDBComp") = myDBComp In each...
5
by: Uzi Baruch | last post by:
Hi! Is there an embedded way to check if a session ends? i have an standard ASP.NET application and i want to check if the session has expired on every "Click" that the user did, and...
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
1
by: tshad | last post by:
I have some code to go through a session collection for my error page routine and I get an error on my objects that I store in session variables. Dim strName as String Dim iLoop as Integer ...
2
by: Frank | last post by:
I am developing with VS.NET 2003 on the ASP.NET 1.1 platform. I don't know how to get around this 'Object reference not set to an instance of an object' error. How should I check to see if a...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
2
by: Don Miller | last post by:
I use a Session variable to store a custom object (all properties contain strings) between postbacks. On occasion, mostly when I change and save code, when I refresh the web page to see the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.