Jump to content

Search the Community

Showing results for tags 'cookies'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. hi i'm running website with many vistors at times i get people who abuse my site i would like to know if there is way to block these users via cookies or php , for example my site have to take action against ips that used to click on link more than 5 times tnx
  2. I hope I am posting in the appropriate place. Although I didn't create this code I did write it while following along with the phpacademy 44 video tutorial on Register & Login. Next I followed the 6 video tutorial on creating a "Remember Me" cookie in order to bypass the login. Unfortunately these 2 series were not designed to go together so I am left with a very complex login system via "Register & Login" and no understanding of how to implement the "Remember Me" feature. Before I go uploading any code or copying & pasting anything I would like to throw out a general question as I've posted this on several message boards & PHP Forums so far to no avail - Is there anyone here who has implemented a "Remember Me" feature into the "Register & Login" series presented by phpacademy? This might be a simple exercise within any other login system but this one seems to have left everyone stumped so far. I will gladly upload any files or make any informatio available if anyone is interested. Otherwise it is a lot work only to risk looking like someone who is asking for handouts.
  3. Hey I was wondering if there is a way where I can write a code that will find the user's previous session if they deleted thier cookie, or if the cookie has been expired in the middle of a session. Thanks
  4. I have any easy question for you, I just don't know for sure how to do it. I have a page (A) and it has an iframe in it with a menu at the top that links other pages into the iframe so I can pop in different sections and sub menus without loading the whole page. It all works fine, but I don't want a user to got directly to any of the pages that should only be inside of the frame directly making it look stupid. I'll call these little child pages (B). Now how can I do it with PHP so pages (B) can only be accessed inside of the iframe in page (A)? A cookie, or is there an easier way? To be honest I don't know much about cookies. Thanks
  5. Everything works except the cookies are not being set, any ideas?, Error reporting is that headers have already been set, I don't see it $uname = $_REQUEST["uname"]; $upass = $_REQUEST["upass"]; $ref = $_REQUEST["ref"]; $uname = str_replace("&", "'", $uname); $uname = str_replace("'", """, $uname); $uname = str_replace("\"", "\", $uname); $uname = str_replace("+", "+", $uname); $upass = str_replace("&", "'", $upass); $upass = str_replace("'", """, $upass); $upass = str_replace("\"", "\", $upass); $upass = str_replace("+", "+", $upass); If ($uname != NULL) { $username="xxxx"; $password="xxxx"; $database="xxxx"; $server="xxxx"; mysql_connect($server,$username,$password); @mysql_select_db($database) or die("Something is broken and needs fixing. Please contact us <a href=\"http://xxxx/contact..../contact.php\"> and report this</a>"); $sqlq="SELECT * FROM xxxx WHERE xxxx = '".$uname."' AND xxxx = '".$upass."' LIMIT 0,1"; $objRS = mysql_query($sqlq); while($row = mysql_fetch_array($objRS, MYSQL_ASSOC)){ $uname = $row["xxxx"]; $suid = $row["xxxx"]; $sname = $row["xxxx"]; $upass = $row["xxxxx"]; } $rows = mysql_num_rows($objRS); if (empty($rows)) { $title = "Log In"; include ("../navigation/header.php"); ?> <div id="contenti"> <div id="contwrap"> <div id="iwrap1"> <? ?> <h2> Log In Failed</h2> The username or password is incorrect, please try again <? } else { setcookie("suid",$suid, time()+14400); setcookie("aka",$sname, time()+14400); setcookie("logged","yes", time()+14400); $title = "Log In"; include ("../navigation/header.php"); ?> <div id="contenti"> <div id="contwrap"> <div id="iwrap1"> <? echo "You have succesfully logged in. <a href=\"".$ref."\">Click here to return to the previous page</a>"; } } else { header( 'Location: ../index.php' ) ; }
  6. I'm working on a five star voting system for a website and I have very limited knowledge of cookies and javascript for that matter. I'm attempting to limit users to only one vote per instance so I'm guessing I'll need some sort of count and a cookie tracking system that could delete after a couple days. I'm not necessarily worried about people clearing cache as the votes aren't incredibly important but I definitely don't want the ability to keep voting via click. Here is what I've accomplished so far: <script> $(document).ready(function() { $('.rate_widget').each(function(i) { var widget = this; var out_data = { widget_id : $(widget).attr('id'), fetch: 1 }; $.post( 'ratings.php', out_data, function(INFO) { $(widget).data( 'fsr', INFO ); set_votes(widget); }, 'json' ); }); $('.ratings_stars').hover( function() { $(this).prevAll().andSelf().addClass('ratings_over'); $(this).nextAll().removeClass('ratings_vote'); }, function() { $(this).prevAll().andSelf().removeClass('ratings_over'); // can't use 'this' because it wont contain the updated data set_votes($(this).parent()); } ); $('.ratings_stars').bind('click', function() { var star = this; var widget = $(this).parent(); var clicked_data = { clicked_on : $(star).attr('class'), widget_id : $(star).parent().attr('id') }; $.post( 'ratings.php', clicked_data, function(INFO) { widget.data( 'fsr', INFO ); set_votes(widget); }, 'json' ); }); }); function set_votes(widget) { var avg = $(widget).data('fsr').whole_avg; var votes = $(widget).data('fsr').number_votes; var exact = $(widget).data('fsr').dec_avg; window.console && console.log('and now in set_votes, it thinks the fsr is ' + $(widget).data('fsr').number_votes); $(widget).find('.star_' + avg).prevAll().andSelf().addClass('ratings_vote'); $(widget).find('.star_' + avg).nextAll().removeClass('ratings_vote'); $(widget).find('.total_votes').text( votes + ' votes recorded (' + exact + ' rating)' ); } </script>
  7. I'm trying out session cookies for the first time, and I have run into some troubles. Im recieving the following errors below; Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at filelocation/filename:3) in filelocation/filename on line 4 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at filelocation/filename:3) in filelocation/filename on line 4 Any help would be great! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tree Quoter</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="content_slider_style.css" /> <link rel="stylesheet" type="text/css" href="form.css" /> <script type="text/javascript" src="js/jquery.1.3.2.min.js" ></script> <script type="text/javascript" src="js/jquery-ui.min.js" ></script> <script type="text/javascript"> $(document).ready(function(){ $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000, true); }); </script> </head> <body> <div id="templatemo_body_top"> <div id="templatemo_body_bottom"> <div id="templatemo_wrapper"> <div id="templatemo_header"> <div id="site_title"> <h1><a href="http://www.treequoter.co.uk"><strong>Tree Quoter</strong><span>Expert tree surgeons, competitive quotes</span></a></h1> </div> <!-- end of site_title --> </div> <div id="templatemo_menu"> <ul> <li><a href="index.html" class="current">Home</a></li> <li><a href="services.html">Get quotes</a></li> <li><a href="blog.html">Get Clients</a></li> <li><a href="gallery.html">More info</a></li> <li><a href="contact.html">Contact Us</a></li> </ul> </div> <!-- end of templatemo_menu --> <div id="templatemo_main_wrapper_01"> <div id="templatemo_main_wrapper_02"> <div id="templatemo_main_wrapper_03"> <div id="templatemo_main"> <div id="templatemo_slider"> <div id="featured" > <ul class="ui-tabs-nav"> <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"><img src="images/content_slider/image1-small.jpg" alt="" /><span>Professional tree felling by expert tree surgeons</span></a></li> <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><img src="images/content_slider/image2-small.jpg" alt="" /><span> Tree removal, a section at a time</span></a></li> <li class="ui-tabs-nav-item" id="nav-fragment-3"><a href="#fragment-3"><img src="images/content_slider/image3-small.jpg" alt="" /><span>Brush chipping and recycling</span></a></li> <li class="ui-tabs-nav-item" id="nav-fragment-4"><a href="#fragment-4"><img src="images/content_slider/image4-small.jpg" alt="" /><span> Stump Grinding, creating new spaces</span></a></li> </ul> <!-- First Content --> <div id="fragment-1" class="ui-tabs-panel" style=""> <img src="images/content_slider/image1.jpg" alt="" /> <div class="info" > <h2><a href="#" >Professional Tree Felling</a></h2> <p>An expert tree surgeon will be able to safely fell a diseased or dangerous tree, sometimes even in confined spaces.... <a href="#" >read more</a></p> </div> </div> <!-- Second Content --> <div id="fragment-2" class="ui-tabs-panel ui-tabs-hide" style=""> <img src="images/content_slider/image2.jpg" alt="" /> <div class="info" > <h2><a href="#" >Tree Removal</a></h2> <p>Sometimes the only safe way to remove a tree is to take away a section at a time, roping as we go.... <a href="#" >read more</a></p> </div> </div> <!-- Third Content --> <div id="fragment-3" class="ui-tabs-panel ui-tabs-hide" style=""> <img src="images/content_slider/image3.jpg" alt="" /> <div class="info" > <h2><a href="#" >Brush Chipping</a></h2> <p>Brush cut from your tree is often chipped and taken away. This can then be spread over garden beds or burnt in power stations.... <a href="#" >read more</a></p> </div> </div> <!-- Fourth Content --> <div id="fragment-4" class="ui-tabs-panel ui-tabs-hide" style=""> <img src="images/content_slider/image4.jpg" alt="" /> <div class="info" > <h2><a href="#" >Stump Grinding</a></h2> <p>Post tree removal, people often ask for their stump to be removed, creating extra space in their bed, or simply for aesthetics.... <a href="#" >read more</a></p> </div> </div> </div> </div> <!-- end of templatemo_slider --> <div id="clientform"> <p>Please enter your details below, and 3 of your local tree surgeons will get in touch! or <a href="login.html">login</a><br /><br/></p> <?php $_SESSION['name'] = $_POST['name']; $_SESSION['email'] = $_POST['email']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['postcode'] = $_POST['postcode']; $_SESSION['type'] = $_POST['type']; $_SESSION['start'] = $_POST['start']; ?> <form action="client_start_2.php" method="post"> <p class="left"><label for="name" class="required">Your Name</label><br> <input class="field required" id="name" name="name" placeholder="Your Name" required tabindex="1" type="text" ></p> <p class="right"><label for="email" class="required">Your Email Address</label><br> <input class="field required" id="email" name="email" placeholder="Your Email Address" required tabindex="1" type="email"></p> <div style="clear:both" /> <p class="left"><label for="phone">Your Phone Number</label><br> <input class="field" id="phone" name="phone" placeholder="Your Phone Number" tabindex="3" type="text"></p> <p class="right"><label for="postcode">Your Full Postcode</label><br> <input class="field" id="postcode" name="postcode" placeholder="Your Full Postcode" tabindex="4" type="text"></p> <div style="clear:both" /> <p class="left"><label for="type" class="required">Type of works</label><br> <select class="dropdown required" id="type" name="type" required="required" tabindex="9"> <option value=""> Please Select </option> <option value="1">Tree Surgery</option> <option value="2">Stump Grinding</option> <option value="3">Tree Surgery and Stump Grinding</option> </select></p> <p class="right"><label for="phone">Ideal Start Date</label><br> <input class="field" id="start" name="start" placeholder="Your Ideal Start Date" tabindex="5" type="text"></p> <div style="clear:both"> <p class="left"><label for="question" class="required">Brief Description of Works</label><br> <textarea class="textarea required" id="description" name="description" placeholder="Job Description" required tabindex="10"></textarea></p> <p class="button"><button tabindex="6" type="submit">Submit</button></p> <div style="clear:both" /> </form> </div> <!-- end of clientform --> </div></div></div></div></div></div></div> <div id="templatemo_footer"> <a href="index.html" class="current">Home</a> | <a href="services.html">Get Quotes</a> | <a href="blog.html">Get Clients</a> | <a href="gallery.html">More Info</a> | <a href="contact.html">Contact Us</a> <br /><br /> Copyright © 2012 <a href="#">Tree Quoter</a> | Designed by <a href="http://www.websites.cx" target="_parent">Websites.cx</a> </div> <!-- end of templatemo_footer --> </div> </div> <!-- end of wrapper --> </div> </div> </body> </html>
  8. Hey guys, So I have this really tricky problem with my login system. I get the cannot modify header information but I havent sent any output ? Here's the error log: [10-Nov-2012 09:38:25 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/sdelkata/public_html/login.php:1) in /home/sdelkata/public_html/login.php on line 16 [10-Nov-2012 09:38:25 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/sdelkata/public_html/login.php:1) in /home/sdelkata/public_html/login.php on line 17 and here's the login.php ( lines 16 and 17 are originally the setcookie lines ) <?php ob_start(); require("connect_db.php"); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); $msg=""; if (mysql_num_rows(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email'"))==0){ $msg = "There is no user named ".wordwrap($email, 33, "<br />\n", 1); }elseif(mysql_num_rows(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email' AND BINARY `password`='$password'"))==0){ $msg = "Wrong password!"; }else{ $id = mysql_result(mysql_query("SELECT `id` FROM `blabla` WHERE `email`='$email' AND `password`='$password'"),0); setcookie("dd", md5($id),time()+60*60*24*365*10); setcookie("ff", md5("1"), time()+60*60*24*365*10); sleep(2); echo "<script>document.location.reload(true)</script>"; } if($msg!=""){ sleep(2); echo "<div id='msgboxred'>$msg</div>"; include "login.html"; } ob_end_clean(); ?> I even added ob_start and ob_end_clean but it still gives me the error. What is weird tho is that it works on my 5.4.4 localhost testing server but doesn't work on the online hosting machine which has 5.3.15 ( php version ). Any help is really appreciated!
  9. Greetings everyone, I really hope someone would be able to help me quickly... I'm not very clued up on ajax,jquery or javascript, and would really love some help in converting the attached js file to use a database instead of cookies. Please guys, thanx in advance.
  10. Hai All, I am Wilson. I have just create a website. I create a log in form and set cookies for it to remember all those data. The log in form work well in mozilla firefox but it failed to log in when using the other browser. I try to figure out what is the problem there, I found that cookies was unable to passing when using other broswer. but when I upload all source file to another domain name or ip address, it can run well for every browser. May I know what is the problem there and how to fix it? Thank you very much for it.
  11. Because I have a multi server setup, I was thinking about using cookies for all session data. Obviously the data will be encrypted. But do you guys have any best practices you would recommend? For example, right now, I look for a cookie call (app_name). if that exists I decrypt the data, unserialize it and see if I can the proper ID (and 1 other validation field). If they do, then I fill the local session with all the data I need and I make sure the cookie has the up-to-date data. Should I not use a cookie with (app-name)? If I just use session_name() and set the session/cookie name? Or will that delete the data in the cookie if it already exists? Any advice would be great! I'm really trying hard not to save session data in the DB to account for the multi-server setup. Thanks!
  12. Basically thought I got this working before and now i'm stuck. I'm setting and getting a cookie using a set function ("setRememberMeToken") and retrieving them using a get function ("getRememberMeCheck") [see functions bellow in the final box]... however when i close the browser the cookie session is lost when i reopen.. I used a browser extension called Cookie-editor in chrome to check and I see nothing saved upon reopening (cookie named "token" as it uses tokens in MYSQL DB). This is the thing, if i run (this code bellow).. it actually saves the session fine and works great... saved in a experimental file I named ~/test/test/cookithing.php. <?php include '../includes/config.php'; function setRememberMeToken($pdo, $user_id) { $token = bin2hex(random_bytes('25')); $expirationDate = time() + (86400 * 7); // <-- 7 days later setcookie("token", $token, $expirationDate, "/"); echo $_COOKIE["token"] = $token; $test = true; $to = date('Y-m-d', $expirationDate); $sql = "INSERT INTO `user_token` (`user_id`, `expires`, `tokenHash`) VALUES (?, ?, ?);"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_id, $to, sha1($token)]); } setRememberMeToken($pdo, 1); echo "<br>"; echo sha1($_COOKIE["token"]); ?> So by vising this page it works!.. however not ideal situation to be in as I need it to get to work upon login... Forgetting about the code above for s second, here is the code I use for login (ask if you need more)... if (isset($_POST['remember-me'])){ setRememberMeToken($pdo, $_SESSION["userID"] ); // <----- set token //echo "<br>"; //echo sha1($_COOKIE["token"]); } and the main functions are here:.. <?php function setRememberMeToken($pdo, $user_id) { $token = bin2hex(random_bytes('25')); $expirationDate = time() + (86400 * 7); // <-- 7 days later (make sure your comments are accurate) setcookie("token", $token, $expirationDate, "/"); $_COOKIE["token"] = $token; $test = true; $to = date('Y-m-d', $expirationDate); $sql = "INSERT INTO `user_token` (`user_id`, `expires`, `tokenHash`) VALUES (?, ?, ?);"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_id, $to, sha1($token)]); } function getRememberMeCheck($pdo) { $stmt = $pdo->prepare(" SELECT users.name, users.user_id FROM user_token, users WHERE tokenHash = ? AND expires > NOW() AND users.user_id = user_token.user_id "); $stmt->execute([sha1($_COOKIE["token"])]); $db_query = $stmt->fetch(); if (!$db_query){ return false; } $_SESSION["loggedin"] = true; $_SESSION["username"] = $db_query['name']; $_SESSION["the_usr_id"] = $db_query['user_id']; $_SESSION["userID"] = $db_query['user_id']; // ADDED DUE TO DESCRIPTION ("PROB WILL BE OK") return true; } function isRemembered() { return isset($_COOKIE['token']); } ?> Can anyone see what I'm doing wrong.. right now I'm fairly clueless..? ____________ Edit: also, my header file contains this (see bellow) also.. include 'includes/remember_token.php'; include 'includes/count_online.php'; if (isset($_COOKIE['token'])) { getRememberMeCheck($pdo); } .. this checks if the cookie is set.
  13. How do I save or what is the syntax to save a button in a cookie? test site test I did try a header like <h3>Hello</h3> but get error with a boot5 button. <code> <?php $mp = "vids/coli.mp4"; $dall ="aaa";// echo "dall=".$dall; $uep = `<button type="button" class="btn btn-warning" onmouseover="show(0)" onmouseout="hide(0)" onclick="skip(-5000) ">0:0:0</button>`; //echo "uep=".$uep; setcookie('mp'.'$mp'.time()+30*24*60*60.); setcookie('dall'.'$dall'.time()+30*24*60*60.); setcookie('uep'.'$uep'.time()+30*24*60*60.); ?> </code> ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.