---
title: Sample code
description: The code snippet below demonstrates the use of the writeTokenToHTTPResponse method:
component: php
page_id: php:setup:pf_php_ik_idpsso_sample_code
canonical_url: https://docs.pingidentity.com/integrations/php/setup/pf_php_ik_idpsso_sample_code.html
revdate: July 5, 2024
---

# Sample code

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);
?>
```
