Tip for Validating Cookies

When displaying and using cookies it is important to validate them especially when they are integral to the functionality of the page.  Make sure to check to see if the cookie is set before displaying it.

<?php
$var1 = 0;
if (isset($_COOKIE['$test'])) {
    $var1 = $_COOKIE['$test'];
}
echo $var1;
?>
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments