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
  • 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.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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
Course of the Month16 days, 3 hours left to enroll

850 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