All Topics  
Session (computer science)

 

   Email Print
   Bookmark   Link






 

Session (computer science)



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, in particular networking
Computer network

A computer network is a group of interconnected computers. Networks may be classified according to a wide variety of characteristics. This article provides a general overview of some types and categories and also presents the basic components of a network....
, a session is a semi-permanent interactive information exchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user (see Login session
Login session

In computing, a login session is the period of activity between a user Logging and logout of a system.On Unix and Unix-like operating systems, a login session takes one of two main forms:...
). A session is set up or established at a certain point in time, and torn down at a later point in time. An established communication session may involve more than one message in each direction.






Discussion
Ask a question about 'Session (computer science)'
Start a new discussion about 'Session (computer science)'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, in particular networking
Computer network

A computer network is a group of interconnected computers. Networks may be classified according to a wide variety of characteristics. This article provides a general overview of some types and categories and also presents the basic components of a network....
, a session is a semi-permanent interactive information exchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user (see Login session
Login session

In computing, a login session is the period of activity between a user Logging and logout of a system.On Unix and Unix-like operating systems, a login session takes one of two main forms:...
). A session is set up or established at a certain point in time, and torn down at a later point in time. An established communication session may involve more than one message in each direction. A session is typically, but not always, stateful, meaning that at least one of the communicating parts needs to save information about the session history in order to be able to communicate, as opposed to stateless
Stateless server

A stateless server is a server that treats each request as an independent transaction that is unrelated to any previous request....
 communication, where the communication consists of independent requests with responses.

Communication sessions may be implemented as part of protocols and services at the application layer
Application layer

Application Layer is a term used in categorizing protocols and methods in architectural models of computer networking. Both, the OSI model and the Internet Protocol Suite contain an application layer....
, at the session layer
Session layer

The Session Layer is Layer 5 of the seven-layer OSI model of networking.The Session Layer provides the mechanism for opening, closing and managing a Session between end-user application processes, i.e....
 or at the transport layer
Transport layer

In computer networking, the Transport Layer is a group of methods and protocols within a layered architecture of network components, within which it is responsible for encapsulating application data blocks into datagrams suitable for transfer to the network infrastructure for transmission to the destination host, or managing the reverse tran...
 in the OSI model
OSI model

The Open Systems Interconnection Reference Model is an abstract description for layered communications and computer network protocol design. It was developed as part of the Open Systems Interconnection initiative....
.
  • Application layer examples:
    • HTTP sessions, which may allow dynamic web page
      Dynamic web page

      Classical hypertext navigation occurs among "static" documents, and, for "web users," this experience is reproduced using static web pages. However, Web browser can also provide an "interactive experience" that is termed "dynamic." Content on a web page can change, in response to different contexts or conditions....
      s, i.e. interactive web pages, as opposed to static web page
      Static web page

      A static web page is a web page that always comprises the same information in response to all download requests from all users. Contrast with Dynamic web page....
      s.
    • A telnet
      TELNET

      Telnet is a network protocol used on the Internet or Local Area Network connections. It was developed in 1969 beginning with RFC 15 and standardized as Internet Engineering Task Force STD 8, one of the first Internet standards....
       remote login session
  • Session layer
    Session layer

    The Session Layer is Layer 5 of the seven-layer OSI model of networking.The Session Layer provides the mechanism for opening, closing and managing a Session between end-user application processes, i.e....
     example:
    • A Session Initiation Protocol
      Session Initiation Protocol

      The Session Initiation Protocol is a Signalling protocol, widely used for setting up and tearing down multimedia communication sessions such as Internet telephony and video calls over the Internet....
       (SIP) based Internet phone call
  • Transport layer example:
    • A TCP
      Transmission Control Protocol

      The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is so central that the entire suite is often referred to as "TCP/IP"....
       session, which is synonymous to a TCP virtual circuit
      Virtual circuit

      In telecommunications and computer networks, a virtual circuit , synonymous with virtual connection and virtual channel, is a connection oriented communication service that is delivered by means of packet mode communication....
      , a TCP connection
      Connectivity (computer science)

      Connectivity, in the context of Computer science, refers to the use of computer networks to link computers to one another, and provide information resources between computer systems and their final users....
      , or an established TCP socket
      Socket

      Socket can refer to:In mechanics:* Socket wrench, a type of wrench that uses separate, removable sockets to fit different sizes of nuts and bolts...
      .


In the case of transport protocols which do not implement a formal session layer (e.g., UDP
User Datagram Protocol

The User Datagram Protocol is one of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer applications can send messages, sometimes known as datagram, to other hosts on an Internet Protocol network without requiring prior communications to set up special transmission cha...
) or where sessions at the session layer are generally very short-lived (e.g., HTTP), sessions are maintained by a higher level program using a method defined in the data being exchanged. For example, an HTTP exchange between a browser and a remote host may include an HTTP cookie
HTTP cookie

HTTP cookies, more commonly referred to as World Wide Web cookies, tracking cookies or just cookies, are parcels of text sent by a Web server to a Web Client and then sent back unchanged by the client each time it accesses that server....
 which identifies state, such as a unique session ID
Session ID

In computer science, a session identifier or session ID is a piece of data that is used in network communications to identify a Session , a series of related message exchanges....
, information about the user's preferences or authorization level.

Protocol version HTTP/1.1 makes it possible to reuse the same TCP session for a sequence of service requests and responses (a sequence of file transfers) in view to reduce the session establishment time, while HTTP/1.0 only allows a single request and response during one TCP session. However, this transport layer session mechanism should not be confused with a so called HTTP session, since it is not lasting sufficiently long time, and does not provide application level interactive services such as dynamic web pages.

Software implementation

TCP sessions are typically implemented in software using child process
Child process

A child process is a computer process created by another process .A child process inherits most of its attributes, such as open computer files, from its parent....
es and/or multithreading
Thread (computer science)

In computer science, a thread of execution is a Fork of a computer program into two or more Concurrency running task s. The implementation of threads and process es differs from one operating system to another, but in most cases, a thread is contained inside a process....
, where a new process or thread is created when the computer establishes or joins a session. HTTP sessions are typically not implemented using one thread per session, but by means of a database with information about the state of each session. The advantage with multiple processes or threads is relaxed complexity of the software, since each thread is an instance
Object (computer science)

In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variable#Computer_programmings to access objects, the terms object and variable are often used interchangeably....
 with its own history and encapsulated variables. The disadvantage is large overhead in terms of system resources, and that the session may be interrupted if the system is restarted.

When a client may connect to any in a cluster of servers, a special problem is encountered in maintaining consistency when the servers must maintain session state. The client must either be directed to the same server for the duration of the session, or the servers must transmit server-side session information via a shared file system or database. Otherwise, the client may reconnect to a different server than the one it started the session with, which will cause problems when the new server does not have access to the stored state of the old one.

Server side web sessions


Server-side sessions are handy and efficient, but can become difficult to handle in conjunction with load-balancing/high-availability systems and are not usable at all in embedded systems with no storage. The load-balancing problem can be solved by using shared storage or by applying forced peering between each client and a single server in the cluster, although this can compromise system efficiency and load distribution.

A method of using server-side sessions in systems without mass-storage is to reserve a portion of RAM for storage of session data. This method is applicable for servers with a limited number of clients (e.g. router or access point with infrequent or disallowed access to more than one client at a time).

In the two scenarios above, using client-side sessions could provide advantages over server-side sessions: in the first case by removing the limitations applied to load-balancing algorithms (which usually translates to load distribution optimisation), and in the second case by allowing the use of sessions in web applications when server disk space or RAM is not available or sufficient for this storage.

Client side web sessions


Client-side sessions use cookies and cryptographic techniques to transparently use sessions in scenarios.

How they work


At the end of execution of a dynamic web page, the value of session variables is calculated, compressed and transmitted to the client by an HTTP response header and stored in a cookie on the client (web browser). At this stage the state resides entirely and only on the client file system (or RAM).

For each successive request, once it has been decompressed, the cookie is forwarded to the server which uses it to "remember" the state of the application on that specific client.

Although this mechanism may suffice in some contexts, it cannot be adopted where confidentiality and integrity are necessary. If one wishes to use client-side sessions instead of server-side sessions, the following must be guaranteed:
  1. confidentiality (optional): nothing apart from the server should access session information
  2. data integrity: nothing apart from the server should manipulate session data (accidentally or maliciously)
  3. authenticity: nothing apart from the server should be able to generate valid sessions


In order to accomplish this, the session data needs to be encrypted before being memorised on the client and modification of such information by any other party should be prevented via other cryptographic means.

HTTP session token

A session token is a unique identifier (usually in the form of a hash generated by a hash function
Hash function

A hash function is any algorithm or function which converts a large, possibly variable-sized amount of data into a small datum, usually a single integer that may serve as an array index into an array....
) that is generated and sent from a server
Server (computing)

A server is a computer program that provides services to other computer programs , in the same or other computer. The physical computer that runs a server program is also often referred to as server....
 to a client
Client (computing)

A client is an Application software or system that accesses a remote service on another computer system, known as a Server , by way of a Computer network....
 to identify the current interaction session. The client usually stores and sends the token as an HTTP cookie
HTTP cookie

HTTP cookies, more commonly referred to as World Wide Web cookies, tracking cookies or just cookies, are parcels of text sent by a Web server to a Web Client and then sent back unchanged by the client each time it accesses that server....
 and/or sends it as a parameter in GET or POST queries. The reason to use session tokens is that the client only has to handle the identifier (a small piece of data which is otherwise meaningless and thus presents no security risk) - all session data is stored on the server (usually in a database
Database

A database is a structured collection of records or data that is stored in a computer system. The structure is achieved by organizing the data according to a database model....
, to which the client does not have direct access) linked to that identifier. Examples of the names that some programming languages use when naming their cookie include JSESSIONID (JSP
JavaServer Pages

JavaServer Pages is a Java technology that allows software developers to create dynamic web page, with HTML, XML, or other document types, in response to a Web client request....
), PHPSESSID (PHP
PHP

PHP is a scripting language originally designed for producing dynamic web pages. It has evolved to include a command line interface capability and can be used in Standalone software Graphical user interface....
), and ASPSESSIONID (Microsoft
Microsoft

Microsoft Corporation is a multinational corporation computer technology corporation that develops, manufactures, licenses, and supports a wide range of computer software products for computing devices....
 ASP
Active Server Pages

Active Server Pages , also known as Classic ASP, was Microsoft's first server-side scripting Active Scripting for dynamic web page. Initially released as an add-on to Internet Information Services via the Windows_NT_4.0#Option_Pack, it was subsequently included as a free component of Windows Server ....
).

External links



See also

  • Login session
    Login session

    In computing, a login session is the period of activity between a user Logging and logout of a system.On Unix and Unix-like operating systems, a login session takes one of two main forms:...
  • Session fixation
    Session fixation

    In computer network security, session fixation attacks attempt to exploit the vulnerability of a system which allows one person to fixate another person's session identifier ....
  • Session poisoning
    Session poisoning

    Session poisoning is to Exploit insufficient input validation in server applications which copies user input into Session variables.The underlying vulnerability is a state management problem; shared state, Race hazard, ambiguity in use or plain unprotected modifications of state values....