Solved

Finding information on connection...

Posted on 1998-07-14
10
185 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
[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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 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