Skip to content
PHP Logo

Is it possible to set multiple cookies independently in PHP scripts?

Yes, it is possible to set multiple cookies independently in PHP scripts by calling the setcookie() function multiple times with different parameters for each cookie. Each call to setcookie() will create a separate cookie with its own name, value, and optional parameters.

php
// Set multiple cookies independently
setcookie('cookie1', 'value1', time() + 3600); // Cookie 1 with value1
setcookie('cookie2', 'value2', time() + 3600); // Cookie 2 with value2
setcookie('cookie3', 'value3', time() + 3600); // Cookie 3 with value3