# PHP cookie if not set

**URL:** <https://forum.kirupa.com/t/php-cookie-if-not-set/199824>\
**Category:** Uncategorized\
**Created:** [September 6, 2006, 12:27pm UTC](https://forum.kirupa.com/t/php-cookie-if-not-set/199824 "2006-09-06T12:27:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesleuth](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@thesleuth](https://forum.kirupa.com/u/thesleuth)\
**Post date:** [September 6, 2006, 12:27pm UTC](https://forum.kirupa.com/t/php-cookie-if-not-set/199824/1 "2006-09-06T12:27:14Z")

</div>

I have this code which sets a cookie to define the width of a table cell…

```php
if(!isset($_COOKIE['barwidth'])) {
        setcookie("barwidth","160");
    }

```

(Code 1)

When I clear my cookie and went to that page which has Code 1, the page did not show the table cell with 160, instead is showed a blank (no value). However, after I refresh, the cell showed up as 160. I believed that after the page was loaded, the cookie was set, how do I use the value right after the page is loaded?
