users logged in script

This is a discussion on "users logged in script" within the PHP Forum section. This forum, and the thread "users logged in script are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 30th, 2007, 08:28
Up'n'Coming Member
Join Date: Jul 2006
Location: manila
Age: 28
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
users logged in script

hello,

i have a startup a website, and i use php with a mysql backend to store information.

my question is, how can i create a "users logged in now" script? i want to have the "users logged in now" part of the site dynamic, instead of having to purge the user login cache (login information is stored as a 1 or 0 in user database)?

right now, when a user logs in, the login field on his database entry becomes 1, but if he doesnt log out by clicking "logout" (i.e. he closes the browser window) he remains "logged in." i only want to show people who are logged in (and clicking) at the time the page is loaded.

thnx
Reply With Quote

  #2 (permalink)  
Old May 7th, 2007, 12:51
Up'n'Coming Member
Join Date: Jul 2006
Location: manila
Age: 28
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
how do i check if user is logged on or not?

i would like to echo different links on each page depending on if the user is logged on or not,

e.g "log on" or "register" if they are not and "change style" if they are,

how do i do this?

thanks
Reply With Quote
  #3 (permalink)  
Old May 7th, 2007, 13:54
New Member
Join Date: Feb 2007
Location: LONDON (UK)
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: users logged in script

sessions...

i think
Reply With Quote
  #4 (permalink)  
Old May 7th, 2007, 16:35
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: users logged in script

Do you want to require users to accept cookies? If so, that's the easy answer. Use sessions and cookies.

If not, you're faced with the problem of transmitting the session id. I'm about to post a question about doing this with $_POST forms. Otherwise AFAIK, you pretty much have to put the session id in the url.

Another approach is to query the member table on each page load, which depends on how much server load you can tolerate.

Unless you want some complex mechanism that will detect the browser's exit, I don't know of any way to log someone out accurately. A lot of sites put a timer on the session. Some allow the user to choose "log me out after * minutes" or "keep me logged in", although I image the latter option generally has a 12 or 24 hour timer or gets caught in a periodic sweep.
Reply With Quote
  #5 (permalink)  
Old May 8th, 2007, 12:05
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: users logged in script

question :.... do sessions expire naturally?..... if so, how long does this take, and if not what are the consequences of not killing them properly?
Reply With Quote
Reply

Tags
logged, script, users

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best script to create users for password protected pages? vandiermen PHP Forum 3 Apr 23rd, 2007 12:22
online image and offline image showing when logged in and logged out Aaron1988 PHP Forum 4 Apr 5th, 2007 17:24
When logged in options Aaron1988 Webforumz Cafe 36 Nov 27th, 2006 15:45
users online, users loggedin benbacardi PHP Forum 3 Jul 5th, 2005 22:14


All times are GMT. The time now is 05:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43