Enabling persistent sessions in a single store

Persistent sessions are useful in B2C stores, although it is possible to enable B2B direct stores with persistent sessions as well. The steps to enable persistent sessions in the stores differ only in the locations and names of the files that need to be altered. In both cases, the store's Logon and UserRegistrationAdd forms require changes. The steps must be completed for all the stores in the site that need persistent sessions.

Before you begin

Ensure that you complete the following task:

Procedure

  1. In your store's Logon form and the UserRegistrationAdd form, add the rememberMe parameter as shown in the following example:
    
    <form method="post" name="Logon" action="Logon" id="Logon">
    ...
    <input type="checkbox" name="rememberMe" value="true">
    Remember Me </input>
    ...
    </form>
    
  2. Modify the URL parameter of the Logon form from
    
    <input type="hidden" name="URL"
           value="OrderItemMove?page=account&amp;URL=OrderCalculate%3FURL%3DLogonForm"
           id="WC_Accouid="WC_AccountDisplay_FormInput_URL_In_Logon_1" />
    

    To

    
    <c:choose>
        
    <c:when test="${!empty WCparam.URL}">
         <input type="hidden" name="URL" 
                value="${WCparam.URL}"
                id="WC_AccountDisplay_FormInput_URL_In_Logon_1" />
        </c:when>
        <c:otherwise>
            <input type="hidden" name="URL"
                   value="OrderItemMove?page=account&amp;URL=OrderCalculate%3FURL%3DLogonForm"
                   id="WC_AccountDisplay_FormInput_URL_In_Logon_1" />
        </c:otherwise>
    </c:choose>
    
    Note: The value of the id attribute differs between stores, but the structure of the code fragment remains consistent.
  3. Optional: If you want the partially authenticated user's logon ID to be populated in the user name entry field of the logon form, change the following code:
    
    <input size="20" name="logonId" value=""
           id="WC_AccountDisplay_FormInput_logonId_In_Logon_1" />
    

    To

    
    <c:choose>
        <c:when test="${!empty param.logonId}">
            <input size="20" name="logonId" value="${param.logonId}"
                   id="WC_AccountDisplay_FormInput_logonId_In_Logon_1" />
        </c:when>
    <c:otherwise>
            <input size="20" name="logonId" value=""
                   id="WC_AccountDisplay_FormInput_logonId_In_Logon_1" />
    </c:otherwise>
    </c:choose>
    
    Note: The value of the id attribute differs between stores, but the structure of the code fragment remains consistent.
  4. Add the following configuration fragment to the WebSphere Commerce Struts custom configuration file for the Stores module:
    
    <global-forwards>
            <forward className="com.ibm.commerce.struts.ECActionForward" 
                     name="RememberMeLogonFormView/
    
    storeID
    " 
                    
    path="/UserArea/AccountSection/AccountDisplay.jsp">
    
                <set-property property="credentialsAccepted"
                              value="
    
    storeID
    :
    credAccept" />
            </forward>
    
    </global-forwards>
    
    
    <action-mappings
    type="com.ibm.commerce.struts.ECActionMapping">         
    
    
           <action path="/RememberMeLogonFormView" 
                    type="com.ibm.commerce.struts.BaseAction">
              <set-property property="https" value="
    
    storeID
    :1" />
              <set-property property="credentialsAccepted" value="
    
    storeID
    :
    credAccept" />
            </action>
    
    
    </action-mappings>
    
    where:
    storeID
    The store ID of the store for which you are enabling the persistent session. This value can be found in the STORE table.
    credAccept
    P to mean that remembered registered users are entitled to accessing this resource without authenticating themselves, or any other value (including NULL) to mean that they must authenticate themselves.
  5. Update actions for all the URLs that remembered registered users are entitled to access without authenticating themselves by setting their credentialsAccepted property to storeID :P.
  6. Update the PERSISTENTSESSION column in the STORE table to enable the persistent session:
    1. Open a session to your database.
    2. Find the STORE_ID of the store you are enabling persistent session for by entering the following SQL statement into the session:
      SELECT * FROM STORE
      
    3. Enter the following SQL statement into your database:
      UPDATE STORE SET PERSISTENTSESSION = 
      configValue WHERE STORE_ID = 
      store
      
      ID
      
       
      

      where:

      storeID
      The ID of the store for which you are enabling persistent session.
      configValue
      A value from the following list that represents the appropriate configuration:
      0
      The rememberMe function is disabled for registered customers and guest customers. This is the default value.
      1
      The rememberMe function is enabled for registered customers only.
      2
      The rememberMe function is enabled for guest customers only.
      3
      The rememberMe function is enabled for registered customers and guest customers.