Link to home
Start Free TrialLog in
Avatar of soniya
soniya

asked on

Greeting visitors on website

Hello,
I want to greet visitors on the homepage of my website. welcoming new and identify existing customers. We have separate page for user registration.
How shall I go about?
Avatar of ljubiccica
ljubiccica
Flag of Slovenia image

You can identify users that already visited your site with cookies...

Once they registrate you make a cookie with their name and once they come back you look tof this cookie...

Than somewhere at the top of your page you write...

//for those who don't have a cookie
Hello and welcome! If you are registered user, you can sign in here...
If not registered, you can register here...

//those with cookies
Wellcome again, Andrew Long. ....

You need a code for that or just the idea???

Ljubiccica
Avatar of UnexplainedWays
UnexplainedWays

Or you do a double, Ip and cookie.

Some people dont allow cookies and some people have changing Ip's
Have you written the user registration page yet?
Avatar of soniya

ASKER

Yes the User registration form is done.
Can you help me with the code ?
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Then in user reg page have

<html>
<head>
<script type="text/javascript" language="JavaScript" src="cookie.js"></script>
<script type="text/javascript" language="JavaScript">
function saveName(theForm) {
  setCookie('name','theForm.firstName.value+' '+theForm.lastName.value,expiryDate,'/')
}
</script>
</head>
<body>
<form onSubmit="saveName(this)">
First name: <input type="text" name="firstName" value="">
Last name: <input type="text" name="lastName" value="">
.
.
.
</form>


and in welcome have

<html>
<head>
<script type="text/javascript" language="JavaScript" src="cookie.js"></script>
<script type="text/javascript" language="JavaScript">
function getName() {
  var name="getCookie('name')
  return (name)?name:'Stranger';
}
</script>
</head>
<body>

<script>
document.write('Hello '+getName())
</script>