Solved

Finding information on connection...

Posted on 1998-07-14
10
179 Views
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.

---LSILes
les@livingscriptures.com
0
Comment
Question by:LSILes
  • 5
  • 4
10 Comments
 
LVL 1

Expert Comment

by:gissing
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....
0
 

Author Comment

by:LSILes
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.

---LSILes
les@livingscriptures.com
0
 
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.

Michel
0
 

Author Comment

by:LSILes
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!

---LSILes
les@livingscriptures.com
0
 
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:

<HTML>
<HEAD>
<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>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<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));
    SetCookie('username',username,largeExpDate,myDomain);
  }

}
else BackAgain = ' back';

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



</BODY>
</HTML>

From CGI:

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

where

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

Michel
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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">

Michel
0
 

Author Comment

by:LSILes
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!

---LSILes
les@livingscriptures.com
0
 

Author Comment

by:LSILes
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...

---LSILes
les@livingscriptures.com
0
 
LVL 75

Accepted Solution

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

To read the cookie in asp you need to do
<%
Dim Cookie_Data
Cookie_Data=Request.ServerVariables("HTTP_COOKIE")
.
%>

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


Michel
0
 

Author Comment

by:LSILes
ID: 1858567
Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now