473,788 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
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="JavaS cript" </script>
<script language="JavaS cript" type="text/javascript">
if (GetCookie("use rname"))
{
write("Hi" + GetCookie("user name"));
}
</script>
</head>
Dec 9 '06 #1
1 2120
acoder
16,027 Recognized Expert Moderator MVP
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
2478
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 need: A system whereby the user only has to register ONCE and he will have automatic entry to ANY page without havinto to RE-LOGIN even if he comes in
4
4932
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 code: Response.Write(Request.ServerVariables); Response.Write("<BR>"); Response.Write(HttpContext.Current.User.Identity.Name);
3
2105
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 automatically log them in. If they don't they wil be taken to the login page. I can get the network id of the user using System.Environment.UserName if I turn off anonymous access but this gived me an access denied error. If I turn on...
7
4282
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 possible for a malicious user to find that cookie and change its value and therefore auto-login as someone else? and if so how can this be prevented?
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10364
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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 we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.