Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/templates/ja_purity/ja_templatetools.php on line 49
Define Session in C# - The Scripts Library Community

Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home C# Define Session in C#

Define Session in C#

E-mail
(1 vote, average: 5.00 out of 5)

Session is a period of time defined between a web application and a user. There is an individual session for each user browsing a web application. A session can be used to place value/objects in it. I could be an alternative use of cookies.
Session contains a key, which help to assign a value to it. A user can have multi session, for example: Session for username, session for IP, session for user behavior, and so on.

A session timeout can be defined in the application by adding it to the web config file. A session can be clear by the application itself, or simply after the timeout elapse. Here are examples of how session works, written in C#:

Session[“Username”] = “user1” ;// store a value in the Username session

Session[“IPAddress”] = ”198.168.11.11” ;// Store a value in IPAddress session

Session[“Username”] = null ; // Clear a Session variable

Session.Abandon();  // Clear all sessions variables

To set a session timeout, look for the following in your web config file:
<sessionState 
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
cookieless="true" 
timeout="20" 
/>
Now you can alter the timeout and put the number that you find appropriate for your application. The 20 in the above example represent 20 minutes of timeout.