Forum Moderators: mack

Message Too Old, No Replies

How to remember users

Some websites log me automatically - how do I set up the same thing

         

Kenton

1:48 am on Dec 4, 2003 (gmt 0)

10+ Year Member



Howdy

when I visit some sites that I am a member of, like WW, I am automatically logged in as me.

How do I go about setting this up on my site?

It's just that I want my logs to show my name when I look at my own site so I can see how often I visit and how often other are. (I have dynamic IP so I can't track that)

I don't have any login facilities on my site as yet (and not really planning to) so if there is an alternate (easier) way of sorting me from *REAL* visitors then that would be great too.

Thanks
Kenton

GaryK

2:13 am on Dec 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a way to do that, but I'm sure there's an easier way.

What I do is have software running on a local server that keeps track of my IP Address and has DynDNS update their records when my IP Address changes. That way I can use a domain name with a dynamic IP Address. Anyway, at the end of the week I extract the list of IP Addresses I've used that week and run a script on the log files from all my websites that creates new log files without my IP Addresses in them. At this point I now have two logs. One is pure. The other shows everyone except me.

GaryK

9:54 pm on Dec 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone have a better way to do what Kenton is trying to accomplish than what I've suggested. If so please share your knowledge with us. Thanks.

bakedjake

9:56 pm on Dec 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



How do I go about setting this up on my site?

It's all done with cookies. When a user is logged in, a cookie is stored on their computer. That cookie's token and a value is recorded in a database.

Whenever you come back, the site looks for that cookie, and checks its token value. If it matches a token value in the database, it knows who you are.

It's fairly trivial to set up, if you've already got a dynamic site and database.

Kenton

10:11 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



Thanks

I knew about the cookies (but not how to set them up) and you say it's trivial to set up. Can you point me to where I can find out about setting up cookies.

Thanks
kenton

bakedjake

10:16 pm on Dec 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What platform?

Kenton

10:39 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



My Website's hosted on an Apache server (I think this is right, I use an .htaccess file)

bakedjake

10:47 pm on Dec 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Here's a good intro in PHP:

http*//www.websitepublisher.net/article/php_cookies/

Also search WebmasterWorld, you'll find some code lying around here for doing it that others are using.