Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Greeting visitors on website

Posted on 2006-06-26
7
Medium Priority
?
481 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:soniya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:ljubiccica
ID: 16983840
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
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16984208
Or you do a double, Ip and cookie.

Some people dont allow cookies and some people have changing Ip's
0
 
LVL 6

Expert Comment

by:LeeHenry
ID: 16985374
Have you written the user registration page yet?
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 3

Author Comment

by:soniya
ID: 16985714
Yes the User registration form is done.
Can you help me with the code ?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 17041812
save this as cookie.js

// --- start of cookie.js file
if (!window.daysToKeep) daysToKeep = 365; // default cookie life...
today      = new Date();
expiryDate = new Date(today.getTime() + (daysToKeep * 86400000));

/* Cookie functions originally by Bill Dortsch */

function setCookie (name,value,expires,path,theDomain,secure) {
   value = escape(value);
   var theCookie = name + "=" + value +
   ((expires)    ? "; expires=" + expires.toGMTString() : "") +
   ((path)       ? "; path="    + path   : "") +
   ((theDomain)  ? "; domain="  + theDomain : "") +
   ((secure)     ? "; secure"            : "");
   document.cookie = theCookie;
}

function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
         offset += search.length
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1) end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
   }
}
function delCookie(name,path,domain) {
   if (getCookie(name)) document.cookie = name + "=" +
      ((path)   ? ";path="   + path   : "") +
      ((domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
// -- end of cookie.js
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17041850
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>


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question