php cookie security

Posted on 2011-05-04
Last Modified: 2012-05-11
Dear Experts,

I'm having a cookie like this to show a banner only once to the user everyday.
should I use a function like htmlspecialchars for security reasons?
thank you

        $_COOKIE['countsss'] = 0;
$countsss = $_COOKIE['countsss'] + 1;
setcookie('countsss',$countsss,time()+60*60*24); //24 hours
Question by:Braveheartli
    LVL 18

    Assisted Solution

    by:Greg Alexander
    I would cleanse everything with mysql_real_escape_string(), you should be good
    LVL 107

    Accepted Solution

    Here is an example showing how to do it.  You can vary the time between splash pages.

    I see nothing wrong with what you have there, but that is not to say that the other code that actually uses the cookie is correct.  If you want to post that part, perhaps we can take a look.  I can think of no reason to use htmlspecialchars().
    LVL 38

    Assisted Solution

    by:Aaron Tomosky
    If you are usin a number in a cookie it's always best to check is_numeric()
    LVL 12

    Assisted Solution

    by:Mohamed Abowarda
    Since you are not using database, you don't need to strip html tags.
    LVL 1

    Author Closing Comment

    thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction and Prerequisites This article describes methods for detecting whether a client browser accepts and returns HTTP cookies and whether the client browser runs JavaScript.  Most client browsers will, by default, be configured to use cooki…
    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now