/    Sign up×
Community /Pin to ProfileBookmark

code is not working

[code]
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE=”JavaScript”>
function setCookie(name, value, expires, path, domain, secure) {

document.cookie = name + “=” + escape(value) +
((expires) ? “; expires=” + expires.toGMTString() : “”) +
((path) ? “; path=” + path : “”) +
((domain == null) ? “” : (“; domain=” + domain)) +
((secure) ? “; secure” : “”);
}
</SCRIPT>
</HEAD>
<BODY>

<BR>
<FORM>
User ID: <INPUT TYPE=TEXT NAME=UserID>
<BR>
<INPUT TYPE=BUTTON VALUE=”Create Cookie”
onClick=’setCookie(“UserID”, document.forms[0].UserID.value,null,”/”,”www.google.com”);’>
</FORM>
</BODY>
</HTML>

[/code]

this code is not setting the domain name in the browser cookie.
how can i correct it ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@cofactorauthorJun 09.2005 — is it impossible ?
Copy linkTweet thisAlerts:
@Orc_ScorcherJun 09.2005 — how can i correct it ?[/QUOTE]Buy Google Inc.

What makes you think you can set cookies for other domains?
Copy linkTweet thisAlerts:
@cofactorauthorJun 09.2005 — >What makes you think you can set cookies for other domains

my book has that code where domain is a parameter to be sent to the setCookie(...) function. do you mean that is a fake parameter ? is that setCookie(....) function from my book faulty ? is the code in my book faulty ? i have copied from the book.

I usued input param as "www.google.com" .
×

Success!

Help @cofactor 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.6,
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,
)...