Jump to content

Search the Community

Showing results for tags 'cookie'.

  • 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

Found 18 results

  1. Hi guys , i am really stuck here .. i am not a php programmer and got a script from a friend to open a link random on click anywhere on site .. this script works great but it only opens a link once a day , i need it to open a link every time the users clicks on the site. i googled a lot and fount that it is the cookie settings , only in all tutorials online they talk about setting cookie time on 0 ... this option is not written in the script i have and there is a tag made , new_Date i can not find any info on those tags like new day , and changing it to 0 breaks the script. does somebody know how to change this script so it works on every click on the site. this script is needed for affiliate links and i need it to open every time someone clicks on something on the site without time delay or a time delay from 1 minute for the main page. but most importent is the code without time delay . if someone wants to help i'll be very thankful course googling is not going to solve this for me .. Thanks the script :::: <script> var puShown = false; var PopWidth = 1370; var PopHeight = 800; var PopFocus = 0; var _Top = null; function GetWindowHeight() { var myHeight = 0; if( typeof( _Top.window.innerHeight ) == 'number' ) { myHeight = _Top.window.innerHeight; } else if( _Top.document.documentElement && _Top.document.documentElement.clientHeight ) { myHeight = _Top.document.documentElement.clientHeight; } else if( _Top.document.body && _Top.document.body.clientHeight ) { myHeight = _Top.document.body.clientHeight; } return myHeight; } function GetWindowWidth() { var myWidth = 0; if( typeof( _Top.window.innerWidth ) == 'number' ) { myWidth = _Top.window.innerWidth; } else if( _Top.document.documentElement && _Top.document.documentElement.clientWidth ) { myWidth = _Top.document.documentElement.clientWidth; } else if( _Top.document.body && _Top.document.body.clientWidth ) { myWidth = _Top.document.body.clientWidth; } return myWidth; } function GetWindowTop() { return (_Top.window.screenTop != undefined) ? _Top.window.screenTop : _Top.window.screenY; } function GetWindowLeft() { return (_Top.window.screenLeft != undefined) ? _Top.window.screenLeft : _Top.window.screenX; } function doOpen(url) { var popURL = "about:blank" var popID = "ad_" + Math.floor(89999999*Math.random()+10000000); var pxLeft = 0; var pxTop = 0; pxLeft = (GetWindowLeft() + (GetWindowWidth() / 2) - (PopWidth / 2)); pxTop = (GetWindowTop() + (GetWindowHeight() / 2) - (PopHeight / 2)); if ( puShown == true ) { return true; } var PopWin=_Top.window.open(popURL,popID,'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,top=' + pxTop + ',left=' + pxLeft + ',width=' + PopWidth + ',height=' + PopHeight); if (PopWin) { puShown = true; if (PopFocus == 0) { PopWin.blur(); if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1) { _Top.window.blur(); _Top.window.focus(); } } PopWin.Init = function(e) { with (e) { Params = e.Params; Main = function(){ if (typeof window.mozPaintCount != "undefined") { var x = window.open("about:blank"); x.close(); } var popURL = Params.PopURL; try { opener.window.focus(); } catch (err) { } window.location = popURL; } Main(); } }; PopWin.Params = { PopURL: url } PopWin.Init(PopWin); } return PopWin; } function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; path=/;' + '; expires=' + expires.toGMTString() ; } function getCookie(name) { var cookies = document.cookie.toString().split('; '); var cookie, c_name, c_value; for (var n=0; n<cookies.length; n++) { cookie = cookies[n].split('='); c_name = cookie[0]; c_value = cookie[1]; if ( c_name == name ) { return c_value; } } return null; } function initPu() { _Top = self; if (top != self) { try { if (top.document.location.toString()) _Top = top; } catch(err) { } } if ( document.attachEvent ) { document.attachEvent( 'onclick', checkTarget ); } else if ( document.addEventListener ) { document.addEventListener( 'click', checkTarget, false ); } } function checkTarget(e) { if ( !getCookie('popundr') ) { var e = e || window.event; var win = doOpen('http://yourlinkurl.url/bannerpage.phphtml'); setCookie('popundr', 1, 24*60*60*1000); } } initPu(); </script>
  2. Hello all, I have a simple PHP page that queries a database and outputs the result set in an HTML table. It works fine. However, the result set is relatively large (2500ish records), so I want to apply a filter. Added an HTML form to the page that lets us filter the criteria. Again, works great. (Used GET method so that the URL could be linked). Here's where my problem comes about. My boss wants the filters to be persistent, both within and between sessions. My first thought was cookies.. so I created a function called Filter() and call it at the top of my PHP document. It reads the cookie and applies the filters into the SQL statement. This works, but is rather kludgy. The problem I have is that when I first access the page, it doesn't seem to see the filters, it displays the full 2500ish record set. However, if I do a CTRL-R to reload the page, it then loads the filters correctly... it's almost like it renders the page before it can read the cookies in the initial pass. Any thoughts on how to improve this, or am I taking a totally wrong approach?
  3. I have two domains - http://domaina.com, http://domainb.com I'm calling domainb.com's url from domaina.com: file_get_contents('http://domainb.com/a.php'); In http://domainb.com/a.php, I'm trying to creating a session or cookie for domainb.com <?php setcookie("key", "value", time()+3600); session_start(); $_session["key1"] = "value1"; ?> But this code is not working. Please help in solving this issue. Thank you.
  4. Hi to everyone, I'm new to the forum and I'm posting here because I ended up in a logical problem for my next script development. I need to get some data of external websites (with vbulletin board), perfectly legal. Using file_get_contents i can print the page content on my server and then use jquery's powerful selectors to get my data. The problem is that these data are shown only to logged in users so i would need this script (maybe using cURL?) to either login to the external website and then persists the connection or maybe if the user who is executing my script is already logged in that website then use his login? (most likely impossible I think..) This is my code so far (found on some sites and merged into this) $data = array('vb_login_username' => 'Scanu', 'vb_login_password' => 'grgfgrgrfbtgbt'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.vbulletin.org/forum/login.php?do=login"); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $result = curl_exec($ch); curl_close($ch); $pattern = "#Set-Cookie: (.*?; path=.*?;.*?)\n#"; preg_match_all($pattern, $result, $matches); array_shift($matches); $cookie = implode("\n", $matches[0]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.vbulletin.org/forum/"); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $result = curl_exec($ch); curl_close($ch); echo $result; ?> It just shows the same page for unregistered users. Any help or advice is appreciated, i'm very new to this type of script..
  5. I need a domain example.com redirects to sub-domain a.example.com when I type on the address bar. <script type="text/javascript"> $(function(){ var city = readCookie('city'); if(city==null && city==''){ window.location.href = 'http://' + city + '.example.com'; } $('#citygo').change(function(){ var city = $(this).val(); createCookie('city', city, 28); window.location.href = 'http://' + city + '.example.com'; }); }); </script> <body> <select id="citygo"> <option value="0">Select City</option> <option value="amsterdam">Amsterdam</option> <option value="newyork">New York</option> <option value="london">London</option> <option value="cardiff">Cardiff</option> </select> </body> The cookie on the server side is not holding so the domain cannot remember sub-domain. What am i doing wrong? Any help will be very much appreciated. <?php $hour = time() + 50400; //Time you want the cookie to last, currently 14 hours setcookie(My_Site_Location, $_SERVER['citygo'], $hour, '/', 'example.com'); if (isset($_SERVER['citygo'])) { $cookies = explode(';', $_SERVER['citygo']); foreach ($cookies as $cookie) { list($cookie_id, $cookie_value) = explode('=', $cookie); if($cookie_id === $name){ self::set_cookie($cookie_id, $value, $expiry, $path, $domain); } } } ?>
  6. Hello, I wanted to ask if cookies are editable and if they are trustable to be secured well enough to store sensetive data. As far as I know some websites are using cookies to store sensitive data such as passwords. Greetings, KubeR.
  7. After a couple days of search google and looking through the plethora of books here on the shelf, I have come to the conclusion that what I am looking for I simply don't have the right terminology for it as the results I am getting are clearly not what I am looking for. Therefore I post in hope that someone here could shine a light onto where I am going wrong. The Brief: I have an IP address lookup script that can use GET or POST to produce the GEO Location of an IP address, fairly simply stuff. However the system is getting abused which is not fair on our other visitors looking to find out those nasties. I would like to LIMIT the amount of lookups, say 10 in any one hour. This is where I hit the proverbial wall, as I am unsure as to how one could achieve this, nor do I have an understanding on what this would be called as my assumed "Limit Form Submits" does not bear fruit. Any help, guidance of RTFMs appreciated.
  8. Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\index.php:17) in C:\xampp\htdocs\header.php on line 143 I am getting sick of this "warning", please help me and tell me how to remove the warning........
  9. I am trying to access the values from "first.php" page to "visit.php", I am able to get the values , however, while creating and destroying cookies, I am facing error. ----------------FIRST.PHP---------------- <?php error_reporting(E_ALL); if(isset($_COOKIE["_user_name"])){ setcookie("_user_name", "", time()-(3600*1000)); echo $_COOKIE["_user_name"]; } ?> <form method='post' action="visit.php"> <input type="text" name="name1"/> <input type="submit" value="Submit"/> </form> ----------------FIRST.PHP---------------- ----------------VISIT.PHP---------------- <?php error_reporting(E_ALL); if(isset($_POST["name1"])) { $name = $_REQUEST["name1"]; echo "Value = ".$name; setcookie("_user_name", $name, time()+3600); } ?> ----------------VISIT.PHP---------------- When I enter name on "FIRST.PHP", I am able to access it on "VISIT.PHP", but I am facing waring Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\counter\visit.php:6) in C:\xampp\htdocs\counter\visit.php on line 7 I am deleting the existing cookie on "FIRST.PHP" and then accessing value from "FIRST.PHP" to "VISIT.PHP", I am trying to create cookie on "VISIT.PHP"..... Can you help me in getting the warning removed ???
  10. Hi, I'm reading Head First PHP and the book talks about how superior the persistence is for using both cookies and session variables by resetting the session variables from existing cookie variables when you open up the browser again. But when you think about it, what's the point of using sessions again in addition to cookies, if when you're using both the cookies are already exposed? That is, I'm not talking about session ID cookies here, I'm talking about just copying the cookie variables straight onto the session variables - not getting an address or anything like that. Hope I made the question clear enough, thanks!
  11. Hi Can you help with my logic here please. I have screen 1 with an optin form to an autoresponder When visitor drops in their email, they get to screen 2 (the thankyou page) with a free tool Is there a service or piece of software that can track them to know if they have subscribed to the autoresponder Then deliver screen 1 or 2 accordingly? ie. screen 1 if they have not subscribed screen 2 if they have subscribed thanks art
  12. Hi I put the following code into my functions.php file. Here's what I want: 1. I want the cookie to be set only when the visitor goes to Post 1. 2. When someone visits Post 2, if they have the cookie, they get redirected to Post 3. If they don't have the cookie, nothing happens. Now it seems to be working, but the problem is sometimes, when the cookie isn't set, I get redirected to Page 3 from the home page :s. I have no idea why. I should mention I know nothing about coding. The code below is stuff I got online, mixed and matched it, and did some trial and error with my blog. function set_newuser_cookie() { $currentURL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //THE ABOVE GETS THE CURRENT URL if (!isset($_COOKIE['subscriber']) && $currentURL == 'http://mysite.com/post1') { setcookie('subscriber', no, 0, COOKIEPATH, COOKIE_DOMAIN, false); //THE ABOVE SETS A COOKIE IF IT FINDS THE CURRENT URL IS /POST1 } } add_action( 'init', 'set_newuser_cookie'); //I DON'T KNOW WHAT THE ABOVE IS, BUT I HEAR IT'S IMPORTANT $currentURL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //THE ABOVE GETS THE URL AGAIN if ( isset( $_COOKIE["subscriber"] ) && $currentURL == 'http://mysite.com/post2' ) : header( "Location: http://mysite.com/post3" ); endif; //THE ABOVE REDIRECTS THE VISITOR TO POST3 ON 2 CONDITIONS: 1. THAT THE COOKIE IS SET, 2. THAT THE CURRENT URL IS /POST2 Please help!
  13. Hi What's the best way to set up a site so that it recognises whether a visitior is subscribed to my site and then delivers them to a specific page? On similar sites i don't see a cookie that holds the email of a subscriber. What's the best way to go about setting this up. thanks George
  14. <?php if(isset($_POST['login']) AND isset($_POST['password'])){ $username = addslashes($_POST['login']); $username = htmlspecialchars($username); $password = addslashes($_POST['password']); $password = htmlspecialchars($password); $passwordm = md5($password); $passwordmd5xx = "XXXXXXXXXX".$passwordm; if(!empty($username) AND !empty($password)){ include('../includes/functions.php'); $query = mysql_query("SELECT * FROM `users` WHERE user_login='".$username."' AND user_pass='".$passwordm."' AND user_status='1'") or die ("Query failed"); $counts = mysql_num_rows($query); if($counts == 0){ include('index.php'); }else{ $rows = mysql_fetch_array($query); setcookie("user_id",$rows['user_id'],time()+14400); setcookie("user_pass",$passwordmd5xx,time()+14400); echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=tools.php'>"; mysql_close($connectdb); } }else{ include('index.php'); } }else{ include('index.php'); } ?> i'm using this code to connect into my panel administration... for some reason there is no cookies set when i'm try to login... ( no cookies => no login ) when i debug the $_COOKIE it return an empty array !! this code work just fine in localhost and the stranger thing it work also in another web server, but not in this web server that i'm using actually... i can't understand where is the problem ?! any suggestion are welcome thank you
  15. Thank you for taking the time to help me! My "check for cookie" code doesn't work. It doesnt show any errors or do anything. Can someone help me understand what I am doing wrong. I am trying to create the code to check for a cookie. If it doesn't exist I want it to display a <div>information</div>. My code to check for a cookie is called usercheck_cookie.html Here is my code to check for a username: <script> function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function checkCookie() { var User_ID=getCookie("User_ID"); if (User_ID!=null && User_ID!="") { alert("Welcome again " + username); } else { alert("You are not a user!); echo "<html><div id="Signup" style="position:fixed;width:1000px;height:500px;top:300px;left:50%;background-color:#220916;"> </div></html>"; } } </script> Here is how I set it into my index.shtml: <!DOCTYPE html> <html> <head> <title>Diamond Book Club</title> <!--#include virtual="usercheck_cookie.html" --> </head> <body onload="checkCookie()"> // and the rest of my website is below Sincerely, Brett Hartel
  16. Hi all, I'm new to the forums and fairly new to PHP. I am glad I found you guys. Does anyone know of a simple script that after someone signs up for a mailing list that it will store a cookie that hides the mailing list completely? (Display none?) This is an external mailing list, (through the InfusionSoft) engine, but hopefully just a simple toggle of the "Sign Up Now" on our web site can just set a cookie to hide the DIV tag. Is this possible?
  17. So I am using this legacy application which is in php 4. I am trying to set the httponly flag and secure flag on. This is my code: header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expireSeconds."; sessionID=".$sessId.";path=".$path."; domain=".$domain."; httponly; secure"); When I test it, The secure flag is set on but the httponly is not. Could it because the URL uses https protocol? Also, does the expire field take seconds. right now, $expireSeconds=14400; How do I modify the code to rectify this if it doesnt expect seconds as a parameter.
  18. 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.
×
×
  • 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.