getSignedCookie([ 'policy' => $customPolicy, 'private_key' => $privateKey, 'key_pair_id' => $keyPairId ]); return $result; } catch (AwsException $e) { return [ 'Error' => $e->getAwsErrorMessage() ]; } } function signACookiePolicy() { $resourceKey = 'https://d13l49jEXAMPLE.cloudfront.net/my-file.txt'; $expires = time() + 300; // 5 minutes (5 * 60 seconds) from now. $customPolicy = << 'default', 'version' => '2018-06-18', 'region' => 'us-east-1' ]); $result = signCookiePolicy( $cloudFrontClient, $customPolicy, $privateKey, $keyPairId ); /* If successful, returns something like: CloudFront-Policy = eyJTdGF0...fX19XX0_ CloudFront-Signature = RowqEQWZ...N8vetw__ CloudFront-Key-Pair-Id = AAPKAJIKZATYYYEXAMPLE */ foreach ($result as $key => $value) { echo $key . ' = ' . $value . "\n"; } } // Uncomment the following line to run this code in an AWS account. // signACookiePolicy(); // snippet-end:[cloudfront.php.signed_cookie_policy.main] // snippet-end:[cloudfront.php.signed_cookie_policy.complete]