Need help setting cookie path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J. Bruce

    Need help setting cookie path

    Does anyone know how to set the path in the script below so that the cookie
    is accessible to all directories?

    TIA

    <SCRIPT LANGUAGE="JavaS cript">

    <!-- Begin
    var expDays = 30;
    var exp = new Date();
    exp.setTime(exp .getTime() + (expDays*24*60* 60*1000));

    function newCookie(){
    xName = document.form.o ne.value;
    SetCookie ('xName', xName, exp);
    xPrice = document.form.t wo.value;
    SetCookie ('xPrice', xPrice, exp);
    }
    function SetCookie (name, value) {
    var argv = SetCookie.argum ents;
    var argc = SetCookie.argum ents.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.toGMTSt ring())) +
    ((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 ();
    }
    // End -->
    </SCRIPT>


  • Klaus Johannes Rusch

    #2
    Re: Need help setting cookie path

    "J. Bruce" wrote:
    [color=blue]
    > Does anyone know how to set the path in the script below so that the cookie
    > is accessible to all directories?
    >
    > function SetCookie (name, value) {
    > var argv = SetCookie.argum ents;
    > var argc = SetCookie.argum ents.length;
    > var expires = (argc > 2) ? argv[2] : null;
    > var path = (argc > 3) ? argv[3] : null;[/color]

    SetCookie(name, value, expires, '/');

    --
    Klaus Johannes Rusch
    KlausRusch@atme dia.net



    Comment

    Working...