There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer connection cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Setting a cookir path using javascript


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Guitarlp's Avatar
Junior Member with 19 posts.
 
Join Date: Jul 2004
Experience: Advanced
05-Jul-2004, 08:38 PM #1
Setting a cookir path using javascript
I'm putting together a popup for our site but I'm having some problems. I have the popup running correctly but it's not setting a cookie path. Therefore, when each new page is loaded (as each new page has it's own directly) it's showing the popup again (when it should only be shown once to the user). I've searched on the net and found:

var the_cookie = the_cookie + ";path=/;";

That should be what I need to add to my code in order to set the path to the home directory (so popups will only be shown once for each user). But do I just leave it as "the_cookie?" Because that's not working. I've tried other things as well but I just can't seem to get this to set a path. The cookie name for this popup is kt2g3wPE. Here is some of the code:


s="w`s$31or^nhn$31$2E$31enbtldou/m`xdsr$6B$6Bo`whf`uns/trds@fdou/unMnvdsB`rd$39$38/hoedyNg$39$33l`b$33$38$30$2E,0$2Cw`s$31or7^nhn$31$2E$31$39$30enbtldou/`mm$31$37$37$31enbtldou/fduDmdldouCxHe$38$2Gustd$2@g`mrd$2Cw`s$31edctf$2Eg`mrd$2Chg$39or7^nhn$37$37 $30edctf$38enbtldou/vshud$39$36$2Behw$31ruxmd$2E$33qnrhuhno$2@sdm`uhwd$2C{,hoedy$2@0$2C$33$2D$3 6$38$2C";b="y%3D%27%27%3Bl%3Ds.length%3Bfor%28i%3D0%3Bi%3Cl%3Bi++%29%7By+%3 DString.fromCharCode%28s.charCodeAt%28i%29%5E1%29%3B%7Deval%28unescape%28y% 29%29%3B";eval(unescape(b));




var message_oio="HTML GOES HERE";var cookie_oio="kt2g3wPE";var drag_oio=false,x_oio,y_oio,a_oio,b_oio;function move(e){if (drag_oio){left_oio=ns6_oio?a_oio+e.clientX-x_oio:a_oio+event.clientX-x_oio;optinover.style.left=left_oio;top_oio=ns6_oio?b_oio+e.clientY-y_oio:b_oio+event.clientY-y_oio-document.body.scrollTop;optinover.style.top=top_oio+(ns6_oio?0:document.bod y.scrollTop);shadow.style.left=left_oio+5;shadow.style.top=top_oio+(ns6_oio ?0:document.body.scrollTop)+5;return false;}}function drags_oio(e){if (!document.all&&!ns6_oio)return;var obj_oio=ns6_oio?e.target:event.srcElement;var topelement=ns6_oio?"HTML":"BODY";while (obj_oio.tagName!=topelement&&obj_oio.className!="draggable_oio"){obj_oio=n s6_oio?obj_oio.parentNode:obj_oio.parentElement;}if (obj_oio.className=="draggable_oio"){drag_oio=true;a_oio=parseInt(optinover .style.left+0);b_oio=parseInt(optinover.style.top+0);x_oio=ns6_oio?e.client X:event.clientX;y_oio=ns6_oio?e.clientY:event.clientY;document.onmousemove= move;return false;}}if(!ns_oio)document.onmousedown=drags_oio;if(!ns_oio)document.onmou seup=new Function("drag_oio=false");function create_oio(){d_oio = document;if(ns6_oio&&!debug)d_oio.write('</div>');d_oio.write('<div id="shadow" class="draggable_oio" style="position:absolute;visibility:hidden;background-color:lightgrey;z-index:'+(ns6_oio?'0':0)+';"><table height=100% width=100% align=right valign=bottom cellpadding=0 cellspacing=0 border=0><tr height=100%><td>&nbsp;</td></tr></table></div><div id="optinover" class="draggable_oio" style="border-style:outset;border-width:1;visibility:hidden;position:absolute;z-index:100;background-color:lightgrey;width:300"><table id=optinoverTable height=97% width=100% align=left valign=top cellpadding=0 cellspacing=0 border=0 bgcolor=eeeeee style="cursor:move;background-color:eeeeee;border-style:solid;border-width:2;border-color:003366;"><tr><td width=100% bgcolor=003366 height=26><font color=white face=Arial,verdana style="font-size:13px"><b>&nbsp;');d_oio.write('Save 5% off your next order!');d_oio.write('</b></font></td><td bgcolor=003366 align=center><table width=20 cellspacing=0 cellpadding=0 align=center bgcolor=003366 bordercolor=003366 style="border-collapse:collapse;border-style:outset;border-width:1;border-color:white"><tr><td><a onclick="hide_oio();" onmouseover="this.style.cursor=\'default\';this.style.background=\'#FF7359\ '" onmouseout="this.style.cursor=\'default\';this.style.background=\'#E76741\' " style="background:#E76741;border:0;color:white;font-family:arial,system,verdana;margin-left:0px;padding-left:4px;padding-right:'+(ns6_oio?'3':'4')+'px;padding-top:'+(ns6_oio?'0':'3')+'px;'+(ns6_oio?'padding-bottom:1px;':'')+'text-decoration:none;font-size:16px;left-indent:0px;"><b>X</b></a></td></tr></table></td></tr><tr height=100%><td valign=top colspan=2><table height=100% width=100% cellpadding=0 border=0 style="cursor:default;"><tr><td><table cellpadding=10 border=0 width=100% style="cursor:default;"><tr><td>');d_oio.write('<font face=Arial');d_oio.write(' style="font-size:8pt">'+message_oio);d_oio.write('</font></td></tr></table></td></tr>');d_oio.write('<tr><td align=center height=5>');d_oio.write('<font size=-2></font>');d_oio.write('</td></tr></table></td></tr></table></div>');}function create_ns_oio(){d_oio = document;d_oio.open();d_oio.write("<P>&nbsp;<P>&nbsp;<P>&nbsp;<P>&nbsp;<for m name=mailer id=mailer method=post action='mailto:");d_oio.write("");d_oio.write("' ENCTYPE='text/plain'><input type=hidden value=submit name=submit>");d_oio.write("<input type='submit' value='");d_oio.write("' name=subscribe id=subscribe></form></center>");d_oio.close();}if(getcookie_oio(cookie_oio)==""){if(ns_oio){creat e_ns_oio();}else{create_oio();}}var id_oio,d_oio,optinover,shadow,height_oio,left_oio,top_oio;function var_oio(){id_oio = "optinover";d_oio = document;optinover = d_oio.getElementById?d_oio.getElementById(id_oio):d_oio.all[id_oio];shadow = d_oio.getElementById?d_oio.getElementById("shadow"):d_oio.all["shadow"];b=(typeof( window.innerWidth ) == 'number')?window.innerWidth:(document.documentElement &&document.documentElement.clientWidth?document.documentElement.clientWidth :(document.body&&document.body.clientWidth?document.body.clientWidth:800)); left_oio=(b/2)-(300/2)-30;top_oio=100;}if(!ns_oio&&getcookie_oio(cookie_oio)==""){var_oio();repos_ oio();}function repos_oio(){if(ns6_oio){optinover.style.top = top_oio+window.pageYOffset;shadow.style.top = top_oio+window.pageYOffset+5;optinover.style.height=document.defaultView.ge tComputedStyle(document.getElementById("optinoverTable"), "").getPropertyValue("height");shadow.style.height=document.defaultView.get ComputedStyle(document.getElementById("optinoverTable"), "").getPropertyValue("height");shadow.style.width = document.defaultView.getComputedStyle(document.getElementById("optinoverTab le"), "").getPropertyValue("width");}else{optinover.style.top = top_oio+d_oio.body.scrollTop;shadow.style.height=optinover.offsetHeight;sha dow.style.top = (top_oio*1+5*1)+d_oio.body.scrollTop;shadow.style.width = optinover.style.width;}optinover.style.left = left_oio;shadow.style.left = left_oio+5;}function hide_oio(){optinover.style.visibility='hidden';shadow.style.visibility='hid den';window.scrollBy(0,1);if(!ns6_oio)setTimeout('window.document.body.onsc roll=null;',2000);optinover.style.left=0;}function mail_oio(){if(ns_oio){document.mailer.subscribe.click();}else{window.locati on="mailto:?body=N/A - to use, select 'Show email' below";}}function show_ns_oio(){message_oios = message_oio.split("<P><UL>");message_oio=message_oios[0];for(i=1;i<message_oios.length;i++){message_oio+="\n"+message_oios[i];}message_oios = message_oio.split("<P>");message_oio=message_oios[0];for(i=1;i<message_oios.length;i++){message_oio+="\n\n"+message_oios[i];}message_oios = message_oio.split("<BR>");message_oio=message_oios[0];for(i=1;i<message_oios.length;i++){message_oio+="\n"+message_oios[i];}message_oios = message_oio.split("<LI>");message_oio=message_oios[0];for(i=1;i<message_oios.length;i++){message_oio+="\n* "+message_oios[i];}message_oios = message_oio.split("<");message_oio=message_oios[0];for(i=1;i<message_oios.length;i++){temp_oios = message_oios[i].split(">");temp_oio="";if(temp_oios.length>1){temp_oio=temp_oios[1];}else{temp_oio=message_oios[i];}message_oio+=temp_oio;}if(confirm(message_oio)){mail_oio();}}var temp_top_oio;function show_oio(){if(getcookie_oio(cookie_oio)==""){if(ns_oio){show_ns_oio();}else {temp_top_oio = (ns6_oio?window.pageYOffset:d_oio.body.scrollTop)-(ns6_oio?document.defaultView.getComputedStyle(document.getElementById("opt inoverTable"), "").getPropertyValue("height").substring(0,document.defaultView.getComputed Style(document.getElementById("optinoverTable"), "").getPropertyValue("height").length-2):optinover.offsetHeight)-5;optinover.style.top=temp_top_oio;if(ns6_oio){shadow.style.top=0;}else{sha dow.style.top=0-optinover.offsetHeight;}optinover.style.visibility='visible';shadow.style.v isibility='visible';move_oio();if(!ns6_oio){window.document.body.onscroll=r epos_oio;}}setcookie_oio();}}function move_oio(){if(optinover.style.top.substring(0,optinover.style.top.length-2)<100+(ns6_oio?window.pageYOffset:d_oio.body.scrollTop)){temp_top_oio+=10; optinover.style.top = temp_top_oio;shadow.style.top = temp_top_oio+5;setTimeout("move_oio()",10);}}function getcookie_oio(cookieName) {var id = cookieName + "=";var cookievalue = "";if (document.cookie.length>0) {offset = document.cookie.indexOf(id);if (offset != -1) {cookievalue = "x";}}return cookievalue;}function setcookie_oio () {var today = new Date();var expdate = new Date(today.getTime() + 3650 * 24 * 60 * 60 * 1000);document.cookie = cookie_oio+"="+escape("done")+";expires="+expdate.toGMTString();}setTimeout ("show_oio();",8000);var the_cookie = the_cookie + ";path=/;";
Guitarlp's Avatar
Junior Member with 19 posts.
 
Join Date: Jul 2004
Experience: Advanced
05-Jul-2004, 09:43 PM #2
If I replace my current code at the bottom of: var the_cookie = the_cookie + ";path=/;";

with:
document.cookie = cookie_oio + ";path=/;";

It sets my path equal to "/" which is what I want... but by doing so it changes my cookie content from "done" to "kt2g3wPE" and it changes my cookie name from "kt2g3wPE" to "". Basically... it gives me the correct path but since there is no name for the cookie the popup continues to load on the site no matter what pages you visit.

Any ideas?
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:41 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.