473,440 Members | 1,688 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,440 software developers and data experts.

How to determine Session alive?

Hi, I write asp.net via c#.
How should I know the client's session alive?

1. if ( Session["uid"].Equals ( null ) )
2. if ( Convert.IsDBNull(Session["uid"]) )
3. if ( Session.Contents.Count == 0 )

Thanks for your kind advice, David.

Nov 17 '05 #1
3 5273
David wrote:
Hi, I write asp.net via c#.
How should I know the client's session alive?

1. if ( Session["uid"].Equals ( null ) )
this would work
2. if ( Convert.IsDBNull(Session["uid"]) )
this would NOT work: "DbNull" is a special signal that a *database field*
contains a null-value, and null is not equal to DbNull(.Value)
3. if ( Session.Contents.Count == 0 )
would also work, although you can leave out the "Contents",
"Session.Count" is enough. MSDN quote:
The Contents property is provided for compatibility with earlier versions of ASP.


Thanks for your kind advice, David.

Nov 17 '05 #2
And there is a fourth one you can try:

Session.IsNewSession
Hans Kesting
Nov 17 '05 #3
hi david,
well a session will always be alive , each time a request is send to the
server a new session is created if needed, the only place where you can know
that a session is gone is in the session_end handler.

what yoiu can do is check if a session is new or old, or if the session
passed certain milestone, you know if it's a new session in the
session_start handler.
You can always chgeck for "milestones" or states checking variables in
session as you do ni your first variant.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"David" <da*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi, I write asp.net via c#.
How should I know the client's session alive?

1. if ( Session["uid"].Equals ( null ) )
2. if ( Convert.IsDBNull(Session["uid"]) )
3. if ( Session.Contents.Count == 0 )

Thanks for your kind advice, David.

Nov 17 '05 #4

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

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
7
by: someone | last post by:
Let's say I have a Session timeout of 20 minutes. If the browser periodically request a graphic file, will that keep its Session alive? What keeps the Session alive? Is it the Session cookie that...
5
by: Tim W. | last post by:
Folks. In a B2B Procurement system we've created, we got following Session-Issue: Configuration: We are using IIS 6.0 and added SQL-Based-Sessions in web.config with a timeout of 240 minutes...
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
4
by: pgmanno | last post by:
Hello all, Here is my question. I have an AxWebBrowser (hereafter refered to as "Browser") control framed in a smart client. The smart client requires logon, and the web app that the Browser...
3
by: Arnost Sobota | last post by:
Dear ASP community, I have a question regarding ASP session variables. My assumption was that a session variable has the same lifetime as the session itself: as a consequence, given that...
4
by: rgparkins | last post by:
Hello I am running out of time with a problem I have running PHP 5.04 and Apache 2.0 and really need help :(. I have a page that stores a variable in session but each time I reload that page the...
9
by: gnewsgroup | last post by:
I am using forms authentication for my web application. In web.config, I have this: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="120"...
3
by: dihola | last post by:
Hi, I have a website running in IIS7 and it seems to be creating a new session for every request I make. The values I store in Session are lost with every request. This is the forms bit in my...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.