%CSP.Session Examples
Complete the following steps to use %session with CSP:
-
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> ...
-
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>
-
Open SignIn.CSP in a Web browser. Note that no values are displayed in the form's fields. Enter text into the form fields.
-
Click SignIn. StateTest.CSP opens and displays the values entered into the SignIn.CSP form fields.
-
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.
SignIn.CSP is one of the example files that accompany the tutorial. For information on installing the example files, read Installing Tutorial Files.