/    Sign up×
Community /Pin to ProfileBookmark

Hi all, first post here goes…

I am creating a cookie that stores a web address. What I’d like to do is update that same cookie from a various other web pages. I am using the same piece of code in each web page and referring to the same cookie name, unfortunately rather than update the one cookie IE just creates new cookies. Is this down to shoddy code or simply how cookies work ?

Any one know ?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJul 15.2004 — [font=georgia]Cookies are restricted to a particular path unless you set the "path" parameter. See http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/cookies.html.[/font]
Copy linkTweet thisAlerts:
@HamSandwichauthorJul 15.2004 — Right.....so what would I specificy in the Path ? Not quite sure how I would use this
Copy linkTweet thisAlerts:
@HamSandwichauthorJul 22.2004 — I've read the page that was suggested...several times...and tried using the Path parameter, but it still dosn't work properly. All I want to do is update the same cookie from different web pages with whatever the current URL is. This is the code that I'm using, can anyone see any obvious flaws ? Would it be because I'm trying to do this on an Intranet ? Any ideas any one ?

<SCRIPT language=javascript>


function putCookie() {


cookie_name = "CSISCookie";
var YouEntered = document.URL;


if(document.cookie != document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}

if (index == -1)
{
document.cookie=cookie_name+"="+YouEntered+"; path="/"; expires=Monday, 04-Apr-2010 05:00:00 GMT";

}

}


</SCRIPT>
×

Success!

Help @HamSandwich spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...