Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2006, 06:15 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default set the cookie file name

Is there a way to set the cookie filename with JS?

Currently it is setting it as 'asp/'

Picco

www.crmpicco.co.uk
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old February 16th, 2006, 06:32 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

This is my code:

Code:
function setCookie(NameOfCookie, value, expiredays)
{
// Three variables are used to set the new cookie.
// The name of the cookie, the value to be stored,
// and finally the number of days until the cookie expires.
// The first lines in the function convert
// the number of days to a valid date.

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

// The next line stores the cookie, simply by assigning
// the values to the "document.cookie" object.
// Note the date is converted to Greenwich Mean time using
// the "toGMTstring()" function.

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
and this is how i call it:

Code:
setCookie('OpenJaw', 'true', '1');
www.crmpicco.co.uk
 
Old February 16th, 2006, 07:51 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Am i able to set the file name in the same manner as IE does....
Cookie:<username>@<web address>

www.crmpicco.co.uk
 
Old February 16th, 2006, 12:57 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

this is my code to delete my cookie on logout
Code:
function delCookie(NameOfCookie)
{

    var c = new Date();
   document.cookie = NameOfCookie+"=;expires="+c.toGMTString()+";"+";";

}

delCookie("Open");
but, its not deleteing it??
is there something i am doing wrong?

i have tried document.cookie = NameOfCookie + "=; expires=Mon, 31 Dec 2001 18:18:33 GMT";

www.crmpicco.co.uk
 
Old February 17th, 2006, 05:04 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

I set this cookie in a folder Inetpub/www/picco/asp
and within a file called net1.asp
Code:
function setOWCookie(NameOfCookie, value, expiredays)
{
    var url = location.href; // the current URL of the page (e.g. airbook.asp)
    var airbook = url.indexOf("air_book");
    var netfare3 = url.indexOf("net_fare3");

    // Three variables are used to set the new cookie.
    // The name of the cookie, the value to be stored,
    // and finally the number of days until the cookie expires.
    // The first lines in the function convert
    // the number of days to a valid date.
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

    // The next line stores the cookie, simply by assigning
    // the values to the "document.cookie" object.
    // Note the date is converted to Greenwich Mean time using
    // the "toGMTstring()" function.    
    document.cookie = NameOfCookie + "=" + escape(value) +
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "domain=localhost";
    // If the current page is the airbook
    if(airbook!=-1)
    {
        var returning = document.getElementById("returning");
        returning.style.visibility="hidden";
        var returning_zelle = document.getElementById("returning_zelle");
        returning_zelle.style.visibility="hidden";
        var OpnJw = document.getElementById("OpnJw");
        OpnJw.style.display="none";                
    }
}
However, i want to access it in Inetpub/www/picco/asp/includes
and within a file called net1_include.asp

But this code below doesn't work, when trying to delete the cookie.
Code:
/*
FUNCTION NAME: delCookie
Deletes the cookie name that is passed to the function,
can be used for OJ and OW cookies
*/
function delCookie(NameOfCookie)
{
    // The function simply checks to see if the cookie is set.
    // If so, the expiration date is set to Jan. 1st 1970.
    if (retrieveCookie(NameOfCookie,"DEL"))
    {
        document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
Any help appreciated.

Picco


www.crmpicco.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Cookie Chapter 8 ? phirun BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 13 May 27th, 2005 11:19 AM
Problem with set cookie chapter 8 stephen_c_ BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 December 15th, 2004 02:35 PM
Use cookie to set main frame npepin Javascript 0 October 18th, 2004 02:01 PM
Set Cookie rowlandk Beginning PHP 5 April 6th, 2004 01:18 PM
getting set cookie value from a script abbylee26 Javascript 1 July 17th, 2003 03:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.