cookie problem

Discussion in 'Javascript' started by alain dhaene, May 21, 2004.

  1. alain dhaene

    alain dhaene Guest

    Hi,

    I get the follow problem.

    A page is locate in C:\Directory\files\pag1.php
    There I call the function setUrl. (all the functions are located in
    C:\Directory\includes

    function setUrl()
    {

    var ckyDatum = new Date;
    ckyDatum.setDate(ckyDatum.getDate()+7);

    var href = document.location.href;
    the_cookie = escape(href);

    document.cookie = 'test=' + the_cookie + '; path=/;' ;
    alert(document.cookie);

    }

    This is OK : the alert results in ' test =
    C\Directory\files\pag1.php


    In a page located in C:\Directory\sub\pag5.php I call the function getUrl
    <script language="JavaScript">
    getUrl();
    </script>

    function getUrl()
    {

    var resultaat;

    resultaat = leesUrl('test');
    alert(resultaat); //OK
    The alert results in
    C\Directory\files\pag1.php

    document.write ("<a href="+ resultaat + "><img
    border='0'src='../afbeeldingen/Algemeen/terugbr.gif'></a>");

    !!!!!!!!!!!!!!!!!!//this is not good. I get the follow a href:
    C:\Directory\sub\c\Directory\files\pag1.php


    }



    function leesUrl(cookieName)

    {


    cookie_array = document.cookie.split ("; ")

    for (x=0; x < cookie_array.length; x++)
    {
    cookieParts_array = cookie_array[x].split("=")
    if (cookieParts_array[0] == cookieName)
    {
    alert (cookieParts_array[1]);
    return cookieParts_array[1];
    }
    }
    }

    What's wrong?

    Alain
     
    alain dhaene, May 21, 2004
    #1
    1. Advertising

  2. "alain dhaene" <> wrote in message
    news:40adca86$0$9876$...

    > The alert results in
    > C\Directory\files\pag1.php
    >
    > document.write ("<a href="+ resultaat + "><img

    border='0'src='../afbeeldingen/Algemeen/terugbr.gif'></a>");
    >
    > !!!!!!!!!!!!!!!!!!//this is not good. I get the follow a href:
    > C:\Directory\sub\c\Directory\files\pag1.php
    >
    >
    > What's wrong?
    >

    document.write will interpret backslashes in a string as escape characters
    unless they are themselves escaped \\.
    Easier to specify URLs using forward slashes '/' only.

    --
    S.C.
     
    Stephen Chalmers, May 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    5,891
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. Shapper

    Cookie and Session Cookie Questions.

    Shapper, Apr 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    588
  3. =?Utf-8?B?UGF1bA==?=

    Cookie Question (IP as domain and cookie file location)

    =?Utf-8?B?UGF1bA==?=, Jan 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,501
    Bruce Barker
    Jan 10, 2006
  4. ad
    Replies:
    2
    Views:
    7,567
    Kevin Spencer
    Jan 27, 2006
  5. =?Utf-8?B?TnVubw==?=

    Convert a PHP cookie to an ASP.NET cookie

    =?Utf-8?B?TnVubw==?=, Jan 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    452
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 31, 2006
Loading...

Share This Page