Skip to main content

%CSP.Session Examples

Complete the following steps to use %session with CSP:

  1. Open SignIn.CSP in Studio. Modify the form's input controls by adding the value attributes shown below. The code displays the values stored in %session in the form's fields.

    ...
    <p>User Name: <input type="text" name="txtUserName" 
    value="#($Get(%session.Data("Usr",1)))#"></p>
    <p>Password: <input type="text" name="txtPassword" 
    value="#($Get(%session.Data("Pwd",1)))#"></p>
    ...
    
  2. Add the following script to StateTest.CSP. This code retrieves from %request the values entered into the form fields on SignIn.CSP and stores them in %session.

    
    ...
    <script language="cache" runat="server">
    Set %session.Data("Usr",1)= $Get(%request.Data("txtUserName",1))
    Set %session.Data("Pwd",1)= $Get(%request.Data("txtPassword",1))
    </script>
    
  3. Open SignIn.CSP in a Web browser. Note that no values are displayed in the form's fields. Enter text into the form fields.

    generated description: requestexample signin20142

  4. Click SignIn. StateTest.CSP opens and displays the values entered into the SignIn.CSP form fields.

    generated description: sessionexample2 signin20142

  5. Now click the browser's “Back” button to return to SignIn.CSP. The form fields display the text entered during the original visit to the page.

    generated description: requestexample signin20142

Note:

SignIn.CSP is one of the example files that accompany the tutorial. For information on installing the example files, read Installing Tutorial Files.

FeedbackOpens in a new tab