Darksat IT Security Forums
January 11, 2026, 08:06:43 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Darksat IT Security Forum
From Firewall Support, AntiVirus Questions, Spyware problems, Linux and Windows Security, Black Hat SEO right down to Website Design and Multimedia
 
  Home Help Search Gallery Links Staff List Login Register  
  Show Posts
Pages: [1]
1  Multimedia & Design / Website Design / Cookie protected with md5, is it secure? on: October 15, 2007, 11:25:30 am
Hi, I want to ask about this piece of code that is used to protect the content of some quotations inside a website. The quotations will only change once in a day, depending on the cookie on the client's browser. $ct is the counter for the quotations.
If we change the $ct and $date from the cookie, it will be checked from the cookie storing the md5 hash of $ct.$date.$password. If it doesnot match, the cookie will be reset back to 0 again. Is this implementation secure enough?

//Do the cookie stuff
   $ct = isset($_COOKIE['ct']) ? $_COOKIE['ct'] : 0;
   $date = isset($_COOKIE['date']) ? $_COOKIE['date'] : date('Ymd');
   if(isset($_COOKIE['hash']) && $_COOKIE['hash'] == md5($ct.$date.$password)) {
      if($date < date('Ymd')) {
         $ct++;
         if($ct >= count($thoughts)) $ct = count($thoughts)-1;
         $date = date('Ymd');   
      }
   }
   else {
      $ct = 0;
      $date = date('Ymd');
   }
   setcookie("hash", md5($ct.$date.$password), time()+$cookielife);
   setcookie("ct", $ct, time()+$cookielife);
   setcookie("date", $date, time()+$cookielife);

The whole code is from *ttp://www.unoriginal.org/thoughts/thought.php?action=source
Pages: [1]
Powered by EzPortal
eXTReMe Tracker
Security Forum
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy
Page created in 0.041 seconds with 17 queries.