473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cookie problem

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
Jul 23 '05 #1
1 1414

"alain dhaene" <a.******@instruct.be> wrote in message
news:40**********************@news.skynet.be...
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.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
2
by: Syed Ghayas | last post by:
Hi, I've been having problem writing a cookie. Everything goes ok but when I supply the .Path property to "/" It just write the cookie when there is no cookie present, but when I try to update the...
7
by: Christoph Pieper | last post by:
Hi, we've the following problem : We have an asp-application which sets the cookie on first login. The cookie will never be touched during user access. The user can work the whole day, but...
2
by: marshalli | last post by:
Hi: I have a problem with writing cookie from Jacascript. My problem is that I have two server, one is A, and the other is B. (1) I call a aaa.html from A. In aaa.html : ... <iframe...
3
by: Ben | last post by:
I'm having problems with cookies from asp.net to asp back to asp.net. It seems like I can set a cookie in asp.net fine, and alter it at will, as soon as asp touches it, asp.net won't have...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
5
by: Miljana | last post by:
Hi, I have one problem with cookies in ASP.NET application. It seems that I can not retreive cookie from Request.Cookies collection. I put cookie in Response.Cookies collection, and after page...
6
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My...
5
by: SJ | last post by:
Hi, In my website, i have a cookie that allows the user to remain logged in for upto 90days. So I'm setting the cookie expiration time to 90 days in the future from the time the user logs in....
29
by: Jerim79 | last post by:
I did try to find the answer to this before posting, so this isn't a knee jerk reaction. What I am trying to accomplish is to have a script that opens a cookie, reads a value, and then use a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.