Session variables are used to associate some data with each visitor.

Creating session variables is easy as shown in the following example:
Java Code:
<%
   String name = request.getParameter( "username" );
   session.setAttribute( "userName", name );
%>
Now lets retrieve value from session variable.
Java Code:
<HTML>
<BODY>
Hello, <%= session.getAttribute( "userName" ) %>
</BODY>
</HTML>