The code snippet below demonstrates the use of the writeTokenToHTTPResponse method:

 <?php    
    # Use and instantiate an agent    
    use pingidentity\opentoken\agent;       
    $myagent = new Agent();      

    # Setup an array of values    
    $myvalues = array(TOKEN_SUBJECT => “$userId”);    
    
    # Generate and write the token to a cookie (assuming that's    
    # our configuration)    
    $myagent->writeTokenToHTTPResponse($myvalues); 
?>