PHP cookie if not set

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

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?