Jump to content

Search the Community

Showing results for tags 'cookies'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 18 results

  1. Hi there Is there anyone who can help a javascript Noob? And explain what is missing in my javascript code, so the pop-up only is displayed once per. session. Because right now, it pops up every time I click to a new page. And the idea is that it is should work like the business or consumer popup on dustin.com. Is my Javascrip code. <!--Modal--> <!--modalpopup Business eller privat--> <script> $(document).ready(function(){ //loads when document is ready if (document.cookie.indexOf('modal_shown=') >= 0) { //do nothing if modal_shown cookie is present } else { $('.modal').modal('show'); //show modal pop up document.cookie = 'modal_shown=seen'; //set cookie modal_shown //cookie will expire when browser is closed } }) </script> <script> $ts.ready(function() { $elm('[data-dismiss="modal"]').onclick = function() { $elm('.container').style.display = 'none'; } }); </script> <!--test--> <script> $ts.ready(function() { $elm('[data-dismiss="modal-footer"]').onclick = function() { $elm('.container').style.display = 'none'; } }); </script> <!---->
  2. function createCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + escape(value) + expires + "; path=/"; } function user_login() { var uname = document.getElementById('input-loginname-homepage').value; var psw = document.getElementById('input-loginpassword-homepage').value; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText != "ERR") { var array = this.responseText.split("|"); createCookie("cookie_user_uname",array[0],365); createCookie("cookie_user_psw",array[1],365); } } } xmlhttp.open('POST', 'ajax/login.php?uname=' + uname + '&psw=' + psw, true); xmlhttp.send(); } Other browser working fine. Chrome just seems to not create the cookies. Chrome Version 61.0.3163.100 And no I am not trying to access the page locally (file://...) It`s an up an running website on the web. (https://...) Returned stuff via AJAX from login.php ist like "randomusername|$2y$12$bH/yQet2GxEae00PUUKmIedtkxaHZCiR5csyAzz3/3J..." Thank you!
  3. I have seen many times my browser doesn't support cookie. Can you suggest how many browsers are not supported.
  4. Hello, I have been developing a website for a school project in html, css and javascript. We'll be using the website for an interactive board game. One of the most important elements of the website are the scoreboard and the game questions. The game questions basically give a specific amount of points if correctly answered. The points will then be sent to the scoreboard, and saves it. The scoreboard makes use of cookies to save the data/reset the data. And here comes my problem.. the scoreboard works great in Internet Explorer and Firefox, but not in Google Chrome. I have followed a tutorial on how to use cookies on w3schools (http://www.w3schools.com/js/js_cookies.asp) to help create the scoreboard. The cookies apparently do not work for me when I use Google Chrome, which is very unfortunate. I would really like the website and cookies to be cross-browser compatible, and therefore I need some help. If anyone could help me out, then that would be great! These are my scripts: index.html <!doctype html><html lang=nl><head> <meta charset=utf-8> <script src="cookie.js"></script> </head><!-- dit is jouw hoofdpagina. zie ook commentaar op pag2.html Script toevoegen op al je pagina's bij je hoofdpagina bij de body onload=checkScore() toevoegen--><body onload=checkScore()> <a href=pag2.html>Klik hier voor 10 punten</a><br> <a href=pag3.html>Klik hier voor 5 punten</a> <!-- deze div moet toegevoegd worden op de plek waar je de score wilt zien --> <div id=score> </div> <!-- button om de scores op nul te zetten --> <button onclick="reset()">Reset</button></body></html> pag2.html <!doctype html><html lang=nl><head> <meta charset=utf-8> <script src="cookie.js"></script> <script> var erbij=10; function terug() { createCookie("erbij", erbij); window.location.assign("index.html"); } </script></head><body> <button onclick="terug()">Terug</button> <button onclick="erbij=erbij+1">punten</button></body></html> pag3.html <!doctype html><html lang=nl><head> <meta charset=utf-8> <script src="cookie.js"></script> <script> var erbij=5; function terug() { createCookie("erbij", erbij); //window.history.back(); window.location.assign("index.html"); } </script></head><body> <button onclick="terug()">Terug</button></body></html> cookies.js function checkScore() { var s=getCookie("score"); if (s != "") { erbij=getCookie("erbij"); if (erbij == "") { erbij="0"; } score= (parseInt(s)+parseInt(erbij)).toString(); createCookie("score", score); } else { score="0"; createCookie("score", score); erbij="0"; createCookie("erbij", erbij); } document.getElementById("score").innerHTML="Score: "+score; } function createCookie(name, value, days) { var expires; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } else { expires = ""; } var t=name + "=" + value + expires + "; path=/"; document.cookie = name + "=" + value + expires + "; path=/"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function eraseCookie(name) { createCookie(name,"",-1); } function reset() { document.getElementById("score").innerHTML="Score: 0"; eraseCookie("score"); eraseCookie("erbij"); } All I need is the cookies to work in Google Chrome. Thanks in advance, Es_Dexter
  5. Hello, I'm currently working on a school project involving a bunch of coding in html, css and js. The project's purpose is to basically build a website containing a 'quiz' system. I've already managed to successfully create one, but I'm not yet fully satisfied with it. The quiz contains 21 questions in total, and each question has their own html page; 21 pages in total. Now I have been using a java code to call a random page when a button is pressed on the home website (index.html). It works properly, but it often redirects me to the same page every time I click the button. I want to prevent it from visiting the same page whenever the button is pressed, until all 21 pages have been visited, at which point it resets the data and starts over. I have been looking for a kind of script for this, but can't seem to find it. My only option would be to ask for help, which is why I'm here. This is the code I am currently using for the page randomizer: var howMany = 20; // max number of items listed below var page = new Array(howMany+1); page[0]="spelopdracht1.html"; page[1]="spelopdracht2.html"; page[2]="spelopdracht3.html"; page[3]="spelopdracht4.html"; page[4]="spelopdracht5.html"; page[5]="spelopdracht6.html"; page[6]="spelopdracht7.html"; page[7]="spelopdracht8.html"; page[8]="spelopdracht9.html"; page[9]="spelopdracht10.html"; page[10]="spelopdracht11.html"; page[11]="spelopdracht12.html"; page[12]="spelopdracht13.html"; page[13]="spelopdracht14.html"; page[14]="spelopdracht15.html"; page[15]="spelopdracht16.html"; page[16]="spelopdracht17.html"; page[17]="spelopdracht18.html"; page[18]="spelopdracht19.html"; page[19]="spelopdracht20.html"; page[20]="spelopdracht21.html"; function rndnumber(){ var randscript = -1; while (randscript < 0 || randscript > howMany || isNaN(randscript)){ randscript = parseInt(Math.random()*(howMany+1)); } return randscript; } quo = rndnumber(); quox = page[quo]; window.location=(quox); } } If there is anything you can do, please let me know. I would really appreciate your help! ^.^
  6. Hi, I am trying to amend a cookie script. I have found this online and when I hit the delete cookies button, I have to refresh the page to see it. How could I do this as the deleteCookie function is resetting the exp time which does it but what do I need to add afterwards to make it refresh automatically? after document.cookie = line function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); <--} i tried location.reload(); and window.reload(); but wasnt working. Any idea? Here is the full code <script LANGUAGE="JavaScript">function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) {var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null;}function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");}function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();window.reload();}var expDays = 30;var exp = new Date();exp.setTime(exp.getTime() + (expDays*24*60*60*1000));function amt(){var count = GetCookie('count')if(count == null) {SetCookie('count','1')return 1}else {var newcount = parseInt(count) + 1;DeleteCookie('count')SetCookie('count',newcount,exp)return count }}function getCookieVal(offset) {var endstr = document.cookie.indexOf (";", offset);if (endstr == -1)endstr = document.cookie.length;return unescape(document.cookie.substring(offset, endstr));}// End --></script></head> <body><script LANGUAGE="JavaScript"><!-- Begindocument.write("You have visited this page for <b>" + amt() + " times.")// End --></script><input type="button" onclick="DeleteCookie('count')" value="Delete Cookies"/> </body> Thanks
  7. Hey all. First post here. I'm having some difficulty with cookies and Safari. I've pasted my code below. isValidUser is a function that queries the database. When I test it out on Chrome it works well. In Safari I'm able to log in, but as soon as I navigate away from the page, the cookies disappear. I've tried several permutations with the URL at the end of setcookie including with or without leading '.' and with or without trailing '/' without success. Any help would be greatly appreciated. Thanks, Keith /*------------------------------------------------------------------- * login * * username: is the person's e-mail address * password: is stored separately *-------------------------------------------------------------------*/function login ($username, $password){ if (!isValidUser($username, $password)) return false; setcookie('username', $username, time()+60*60*24*365, '/', '.northernlightsnordic.org'); setcookie('password', md5($password), time()+60*60*24*365, '/', '.northernlightsnordic.org'); return true;} //end login/*------------------------------------------------------------------- * logout * * *-------------------------------------------------------------------*/function logout (){ setcookie('username', "", time() - 3600, '/', '.northernlightsnordic.org'); setcookie('password', "", time() - 3600, '/', '.northernlightsnordic.org'); return true;} //end logout
  8. Hi, I have a button on my page and it links to a page that has a security notice on it, for the user to login the user has to agree that they've read this and then they click on the login in process. Is it possible if the user has read this previously(using cookies) that they are brought to the login page without showing the security page?The process is as follows:1. User clicks login.2. Depending on if the user has clicked "I have read this" the user will be brought to the login page..... if they have not read the message before then they will be brought to the security page.Hope this makes sense.Please any help would be greatly appreciated?ThanksDavid
  9. I am writing a code for a forum system that uses cookies and was wondering what the rules are about using the functions found on http://www.w3schools.com/js/js_cookies.asp for my code...is that a nono? I am writing the code myself just using the functions for setting or getting a cookie.
  10. I'm trying to set a cookie for a user *only* when they click a certain link. My code is in ASP.The code I'm using looks like this: <a href="/backend/" rel="external" id="footlink" onclick="<% Response.Cookies("mobile") = "Full" Response.Cookies ("mobile").Expires = DATE + 30%>"> Full Site </a> But it's not working, it's setting the cookie even though the link isn't clicked. What can I do to fix this?
  11. 1° - Sorry my English, I'm using Google translator. Hello, I'm trying to create a tool to change the background color of the site (blogger), but the way it did, it does not save the option of the visitor, every time the visitor has to click on the color. What code could I use to save cookies, or this way is impossible? See the code I'm using: <center><a href="#" onclick="javascript:document.body.style.backgroundColor='#59141b';"><img src="http://4.bp.blogspot.com/_dsEG33PDaHw/S32TTX4H60I/AAAAAAAAAJU/qYc4BYZclgg/s200/body-rojo.png" /></a><a href="#" onclick="javascript:document.body.style.backgroundColor='#1d2d05'; document.body.style.backgroundImage='http://1.bp.blogspot.com/-j5vpiqnwsd8/t_7bvccefoi/aaaaaaaae0g/wfkeypr5jm8/s1600/testelow.jpg';"><img src="http://2.bp.blogspot.com/_dsEG33PDaHw/S32TTyfDggI/AAAAAAAAAJk/9x17-Ec7Dnw/s200/body-verde.png" /></a><a href="#" onclick="javascript:document.body.style.backgroundColor='#15435a'; document.body.style.backgroundImage='http://1.bp.blogspot.com/-j5vpiqnwsd8/t_7bvccefoi/aaaaaaaae0g/wfkeypr5jm8/s1600/testelow.jpg';"><img src="http://4.bp.blogspot.com/_dsEG33PDaHw/S32TLXeztWI/AAAAAAAAAI0/7hWfrfWsdKU/s200/body-azul.png" /></a> <a href="#" onclick="javascript:document.body.style.backgroundColor='#222'; document.body.style.backgroundImage='http://1.bp.blogspot.com/-j5vpiqnwsd8/t_7bvccefoi/aaaaaaaae0g/wfkeypr5jm8/s1600/testelow.jpg';"><img src="http://2.bp.blogspot.com/_dsEG33PDaHw/S32TMY3FA9I/AAAAAAAAAJM/6Hx0CAagVOQ/s200/body-negro.png" /></a></center>
  12. Are they the same or are they different?
  13. dalawh


    I was looking at http://www.w3schools.com/js/js_cookies.asp and I was wondering if there was something more detailed on cookies. How do cookies look like? Are they just like a text in a document? If you look at the getCookie function, it only gets one line from the cookie, which I assume is because of the setCookie function only creates 1 line, but isn't a cookie normally larger or are cookies individually defined/created by the web designer and not the browser itself? What does "unescape(y)" do?
  14. Okay, I understand what it does, but I'm having troubles understanding the process of the set/getCookie functions given as examples in the w3schools tutorial.I'm a jQuery junkie trying to ramp up to serious scripting (eventually with Ajax and PHP as its becoming apparent). While the school lessons have been invaluable I notice they don't always have a comprehensive list of objects, methods, or actions that can be done. For instance in the Cookie examples, how where does 'exdays' get defined, what do escape() and unescape() do, etc. I understand parts but others seem completely unexplained. Are there any more comprehensive explanations of the cookie?Also, another example, they talk about the setTimeout and clearTimeout, but I never saw setInterval anywhere... that seems like an important thing to leave out of the school so I'm assuming there's 'gotta be a site out there where a full list of events and objects is being updated more regularly.Thanks!
  15. Hi I am having trouble understanding how to make Cookies work. i have a fader on a page that you can move. i am justing the jquery.mobile.-1.0.min.jsbut every time i move off this page and come back to it the fader will go back to its default value. I was wondering if there was a way of keeping the value to the same state on return to the page. Help would be grate.
  16. Hi I have finaly managed to get a cookie to save the data i want it to. I now have a problem that it saves it with Undefined after it. and when i try and pull the information out i will either get Undefined displayed in my webpage or the information i saved with the word undefined after it. how do i define the code i am putting in to the cookie as text. i am using the code from the following website www.jslab.dk.
  17. Hi, I have just started learning php and I am trying to make a mobi site send a cookie so that visitors can switch between mobile and full site views. I feel like I have tried everything. I don't think the cookie is sending. I am using Google Chrome to search for the cookie, but nothing comes up. Is the following code right?I have placed it on the first line of code "before any html is sent"(according to the tutorials). <?php $expireDate = time() +3600; setcookie("testcookie", "formywebsite", $expireDate, "/", "mobi.website.com");?>
  18. Hi, I'm trying to load a Script once per day using cookies but I can't make it !!I've found this cookies tutorial that opens a pop up once per day <script type="text/javascript">var expDays = 1; // number of days the cookie should last var page = "only-popup-once.html";var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes"; function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null;} function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");} function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();} var exp = new Date();exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); function amt(){ var count = GetCookie('count') if(count == null) { SetCookie('count','1') return 1 } else { var newcount = parseInt(count) + 1; DeleteCookie('count') SetCookie('count',newcount,exp) return count }} function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr));} function checkCount() { var count = GetCookie('count'); if (count == null) { count=1; SetCookie('count', count, exp); window.open(page, "", windowprops); } else { count++; SetCookie('count', count, exp); }} window.onload=checkCount;</script> But, I want to load this script file once per day https://sites.google.com/site/alakwad/file-cabinet/open.js Any help ?
  • Create New...