473,406 Members | 2,467 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,406 software developers and data experts.

how to check Session is empty or not

Hi,
Iam using like this
string gs=Session["site"].ToString();
but in my code Session is empty so its giving some runtime error
now i want to give condition that if session is empty i want to do another process how to give condition if session is empty
Jun 9 '08 #1
2 3688
dip_developer
648 Expert 512MB
use

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.     if (!(Session("site") == "")) { 
  4.  
  5.         //do your needful 
  6.  
  7.     } 
  8.  
Jun 9 '08 #2
Plater
7,872 Expert 4TB
Well there's this, for if it's a new session
Expand|Select|Wrap|Line Numbers
  1. Session.IsNewSession
  2.  
And
Expand|Select|Wrap|Line Numbers
  1. Session.Keys.Count
  2.  
Jun 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: The Plankmeister | last post by:
Hi... I'm using session_set_save_handler() and have defined some functions to store session data in a database. It all works marvellously. Except for one small thing. If I do something like: ...
3
by: Michelle | last post by:
Hi all, I am trying to store data in a $_SESSION variable (an array), but it reverts to empty every time my page is refreshed (due to a submit button click). I read the answer to the post...
1
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
9
by: Patrick | last post by:
Hello I'm running two Webservers Using ASP.NET. both are running the same ASP.NET Application, with <sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424"...
2
by: ronchese | last post by:
I'm noticing this since I started developing a website project: my session variables are getting empty! I did a real easy test, and I checked my session variable is getting empty!! What is...
3
abdoelmasry
by: abdoelmasry | last post by:
Hi Friends i need help in sessions im passing variables between pages using sessions this is the main page thats mean the home page the main page have table to show messages for users , it have...
0
by: David | last post by:
Hi, Every two seconds, the client callback starts sending a value to the server (via javascript). That value can be empty or not. The session variable "flag" gets the value "1" if the value is...
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.