473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

User Login via Prompt Popup & Set / Get cookie JS not functioning

8
I use a popup / prompt requesting the visitor to enter a USERNAME so after the user clicks SUBMIT on the prompt all the pages in the site should greet the user with Hi, USERNAME.

But there are two problems.
1. From another page in the site, when I return to the HOME page, the prompt reappears even though I've already entered a USERNAME.

2. The other pages don't greet the user. The Hi, USERNAME doesn't appear.

Could someone offer some help with this?
I've been looking at the code too long to see where the mistake(s) are.
Thank you very much.
TokyoJ

The HOME page / default URL page has this:
<head>
<script language = "JavaScript">
<!--
function writeCookie()
{
var username = prompt("What's your name?", "");
var username = "username=";
document.cookie = username;
}
// -->
</script>
</head>


Then all other pages have this:
<head>
<title> Contact Details </title>
<script language="JavaScript" </script>
<script language="JavaScript" type="text/javascript">
if (GetCookie("username"))
{
write("Hi" + GetCookie("username"));
}
</script>
</head>
Dec 9 '06 #1
1 2103
acoder
16,027 Expert Mod 8TB
See this link and the example page. If the pages which attempt to access the cookie are from a different sub-domain, you will need to set the domain of the cookie too.
Jun 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: | last post by:
Please help. After a number of wrong turns and experiments I need advice on login management system to secure our web pages without inconveniencing our visitors or our internal staff. What I...
4
by: Dave | last post by:
Hi, I have a dev machine, part of a domain, with a site set to Integrated security only. I want to determine the username of person accessing the page. When I run the page with the following...
3
by: Don | last post by:
I'm using FROMS authentication and want to automate the login. Right now I force the user to manually log in. I would like to detect the users network userName and if they have an account I will...
7
by: monomaniac21 | last post by:
hi i have a php site which allows users to save a cookie on their computer which stores their user id details and allows them to auto- login. i'm wondering whether this is safe, is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.