Finding information on connection...

Posted on 1998-07-14
Medium Priority
Last Modified: 2013-12-25
I know about browscap, and how to get some of the browser information, but I want to know if there is any way to get a user's e-mail address just from being connected to your web site.  If there is not any "generic" or built-in function that can do this, is there a software package that might work?  I'd much rather a built-in function, but I'll give points to anyone who can direct me to a software package (just as long as it is a very good package).  

I know that I could have a user type in there information to logon to the page (or a certain part of it), but I want the ability to pull it up immediately without any prompts.  Reason being, just to build rapport, e.g.  User John Doe connects to your web site, and immediately he gets a nice warm welcome message saying something like, "Welcome back John.  We missed you."  I'm sure that I could do this with cookies, but I'm not sure that's the way I wanna do it.  Is there any other way around this?  Please give me some ideas people.  You'll get the points if you can satisfy the question in the first paragraph (above) or give me an even better way to do this.  Thanks!

Oh, and we're using IIS4 on NT 4.0 just in case you need to know.

Question by:LSILes
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
  • 5
  • 4

Expert Comment

ID: 1858557
The simple answer is that there is no way of getting a users email address just by them connecting to your web site. If it were an intranet then you may have some joy with an ASP/DLL arrangement which could look up their email address in Exchange Server using their network user id, but in general terms you will have to ask the visitor to type in their email address and use a cookie on their machine or store it on your server against their IP address ready for their next connection. (this will be very unreliable for user's who's ISP allocate their IP addresses dynamically at each connection).

Just my 2p's worth....

Author Comment

ID: 1858559
Hmmm...  well, looks like I'll have to change my question a bit then, eh?  Can someone provide me with sample code on how to do the cookie bit?  I have had a tad of experience with cookies, but not for a while, so...  

Also, with cookies, shouldn't I be able to get the information from their computer (only after they've typed it in the first time) without needing them to type their e-mail address or anything?  I thought you could at least do that, but let me know if I'm wrong.  Thanks for the comments all!  Please continue to feed the hungry fool.

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1858560
A cookie will hold whatever you put in to it (size limitations do apply)
It will be sent to your server with each request for a new page and is available to JavaScript IN the pages on all pages in the path set in the cookie (but only within YOUR domain)

ASP sets session id's in cookies

cgis can set and get cookies

JavaScripts in pages can set and get cookies...

For casual visits you can hold the name and the number of times and the date of last time visited.
For clients/customers you could hold a small token with a key to a database record on your server.

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.


Author Comment

ID: 1858561
Well, I guess that's as good as it gets.  But, I'll wait until someone gives me some example code (and please make it good) before I fork out the points.  Thanks!

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1858562
I made the comment because you might want to refine the question.

Since this is the Web Authoring section I did not want to lock you into a technique.

Here is one in JavaScript:

<TITLE>Get and set name cookie</title>
<SCRIPT LANGUAGE="JavaScript"><!-- // hide
// Script is a cleaned and modified version of one found at JavaScript World.

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   return null;

function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path    = (argc > 3) ? argv[3] : null;
   var domain  = (argc > 4) ? argv[4] : null;
   var secure  = (argc > 5) ? argv[5] : false;
   // values must be urlencoded (escaped) - some early versions of MSIE 3 does not have escape()??
   document.cookie = name + "=" + escape (value) +
   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
   ((path == null) ? "" : ("; path=" + path)) +
   ((domain == null) ? "" : ("; domain=" + domain)) +
   ((secure == true) ? "; secure" : "");

<SCRIPT LANGUAGE="JavaScript"><!-- // hide
var username = GetCookie('username');
var BackAgain = '';
if (!username) {
  username = prompt('Please enter your name (otherwise press cancel)',"");
  if (!username) {
    alert('Its ok if you dont want to tell me your name');
    username = 'WebSurfer';
  else {
    // don't set the username cookie.... because the user refused to tell you.
    // they will be prompted next time....
    pathname = location.pathname;
    myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
    // set expiry date to 1 year from now.
    var largeExpDate = new Date ();
    largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));

else BackAgain = ' back';

document.write('<H3>Welcome'+BackAgain+', '+username+'</H3>');
We have the following on the agenda


From CGI:

Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure


NAME           The name you whish to reference the variable with
VALUE          The value to associate with this variable.
                      NOTE: Cookie Length is limited to 4K
DATE            Is the time at which the cookie information expires and will be
                     "forgotten" by the browser. If it isn't set then the Cookie will be
                     forgotten when the user closes their browser.
                     NOTE: The date needs to be in the following format.
                     'Wednesday, 09-Nov-99 23:12:40 GMT'
DOMAIN        Is a host or domain name for which the cookie is valid.
PATH           Specifies a subset of the URLs at that server for which the cookie
                    is valid (use / for the complete server).
SECURE      If you include "secure" in your cookie, then the cookie will only be
                    transmitted over an SSL connection.

It will be returned to the server as HTTP-COOKIE

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1858563
PS The Set-Cookie in the cgi is of course an HTTP header. It may therefore also be set in the page with
<META HTTP-EQUIV="Set-Cookie" CONTENT="same parameters as cgi">


Author Comment

ID: 1858564
I'm sorry to deny your answer, but if you read my comment, you'll know why.  Also, I would appreciate it if the person that actually does send me some real code would write it in ASP.  Thanks!


Author Comment

ID: 1858565
Uh, er.... I feel like a dip$#!*....  I guess I didn't scroll high enough the first time I look at it.  I apologize Michel...  just post an answer again, and you'll get the points.  Sorry, sorry, sorry...

LVL 75

Accepted Solution

Michel Plungjan earned 400 total points
ID: 1858566
Thanks - can happen

To read the cookie in asp you need to do
Dim Cookie_Data

Remember to set the path in the cookie so other pages/programs at your site will be allowed to get at them


Author Comment

ID: 1858567

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

777 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