Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    :: how can i check for cookies when...

    i have 2 database websites set up on one server:

    http://10.10.20.11/Cdatastore.nsf/welcome

    http://10.10.20.11/KAMToolbox.nsf/la...nview&count=10

    now, due to the muppets in IT customising IE so much i have to run a .hta file to correct the registry etc so the first website forces the user to run the .hta file then sets a cookie.... so that it doesnt look to run the file on a return visit

    now, ideally i would like to centralise the fix process and get the 2nd werbsite to simply check for the cookie that the first website has done - if not to forward it to that page...

    is this possible? im not too hot with cookies (havent had time to look into them really) so keep it simple plz

    thanks all!!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Since both sites are on the same machine, the first site can set a cookie and specifying the cookie path as / (root) so that the cookie is also accessible to site 2. You don't have to specify the cookie domain since the default is the domain creating the cookie.

    I don't know how you create cookies in Notes Domino but here's how to do it in javascript.

    document.cookie = "domino_cookie=blah;expires=" + new Date("01/01/2010").toGMTString() + ";path=/";

    Take note that if the user accesses the first site using IP address and a cookie is created and then the user accesses site 2 using hostname, the cookie will never be retrieved by site 2. The host from the domain name must matched.

    Here's more info of the Cookie Specification

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    thx m8... im actually not using notes for the cookie usage - just for the security and ease of database usage..

    my cookie script page looks like this:

    Code:
    expDays = 365; 
    
    var fix = 'http://www.simonsintranet.com/files/fixes/fix240804.hta'
    var fixdate = '24th August 2004';
    
    var fix9x = 'http://www.simonsintranet.com/files/fixes/fix240804.hta'
    var fixdate9x = '24th August 2004';
    
    //change the fix number in $$HTMLHead and setNewCookie() function (2x places)
    
    function launch() {
    	window.open(fix9x)
    }
    
    // ##########################################################################################
    
    function updatefix() {
    
    	document.getElementById('fixer2').innerHTML = '<a href="javascript:history.go(-1)"><img src="continueicon.gif" border="0" align="absmiddle"> Click here to continue</a>';
    }
    
    // ##########################################################################################
    
    function writefix() {
    
    if(opsys!="Win 9x") {
    	document.getElementById('fixer2').innerHTML = '<a href="' + fix + '" onClick="setNewCookie(); updatefix()"><img src="mediicon.gif" border="0" align="absmiddle"> Fix for ' + fixdate + '</a>';
    	}
    
    else {document.getElementById('fixer2').innerHTML = '<a href="javascript:;" onClick="launch() ; setNewCookie();  updatefix()"><img src="mediicon.gif" border="0" align="absmiddle"> Fix for ' + fixdate9x + '</a>';
    	}
    }
    
    // ##########################################################################################
    
    function showCookieHistory() {
    
    if(document.cookie!="") {
    	var cookieinfo = document.cookie.split('_')[1];
    	cookieinfo = cookieinfo.split('=')[0];
    	document.write(' | Most recent update: ' + cookieinfo)
    	}
    }
    
    // ##########################################################################################
    
    function get_cookie (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 get_cookie_val (j); 
    i = document.cookie.indexOf(" ", i) + 1; 
    if (i == 0) break; 
    } 
    return null;
    }
    
    function get_cookie_val(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    
    function set_cookie (name, value,expires) {
    var argv = set_cookie.arguments; 
    var argc = set_cookie.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 delete_cookie (name) { 
    var exp = new Date(); 
    exp.setTime (exp.getTime() - 1); 
    var cval = get_cookie (name); 
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
    
    function checkCount() {
    var count = get_cookie('poponce');
    if (count == null) {
    count=1;
    var exp = new Date(); 
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    set_cookie('poponce', count, exp);
    
    //dothis()
    }
    }
    
    function setNewCookie() {
    var count = get_cookie('poponce_240804');
    if (count == null) {
    count=1;
    var exp = new Date(); 
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    set_cookie('poponce_240804', count, exp);
    }
    }
    
    function dothis(){
    document.location.href="fixespage"
    }
    i then check for the cookie by:

    Code:
    if((document.cookie.indexOf('poponce_240804')==-1) && (document.location.href.indexOf('fixes')==-1 )) {
    	document.location.href='fixespage'
    }
    when i synchronise the test environment to the actual server both will be on a server name 'notes1' but the second site will be in a subfolder on that server - hope that makes sense... i go on hols after tomorrow so im not really able to concentrate today!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    btw - i modified the above script so if you see that i am doing thisng in a round-a-bout way plz tell me where im going wrong
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    I don't know what your exact problem is and what the hta is for.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    i just need a way so that website1 can create cookies that website 2 can read - if that makes sense... - they will be on the same server

    the HTA is just to disable content advisor, delete a couple of files on win95 (yes we still have 150 or so win95 users!!!) and do some reg fixes to change the way powerpoint is displayed
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Since the 2 sites are on the same machine, you just create and read cookies as you normally do in a single site. You just have to set the path to "/" as I described in my first post.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    doh! was a bit busy yesterday and didnt realise how easy that was! doh! thx m8!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •