[SOLVED] Don want same person to login at the same time

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
ng_king
Forum Newbie
Posts: 4
Joined: Tue Apr 20, 2004 10:22 pm

Don want same person to login at the same time

Post by ng_king »

Pls help:

I dun want to let the same login ID to login at the same time. how can this be done. pls give me some guidance.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

i would have a flag saying in the db 1 being loged in and 0 being not...but this presents a problem...if the person does not logout and close the browser but they try to log back in they wont beable to ...but what you could do is after 30 mins from loggin in the script updates the flag to 0

hopefully this helps...and maybe there is an easyer solution.

[my 100th post w0ot w0ot]
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I assume you are using a database of some sort, as you didn't mention this. You might want to take ideas from this: viewtopic.php?t=19355

If you do not know what a "useronline script" is, try searching for it in these forums.

Take a look at it, and get back if you still get stuck. It isn't completely what you wanted, but with just abit of rewriting, it would suit you greatly.
ng_king
Forum Newbie
Posts: 4
Joined: Tue Apr 20, 2004 10:22 pm

Post by ng_king »

The method u suggest is not suitable from my concept. ok if the same user login after 30 mins then there will be 2 same user using the same account. i dun want the 2 user to login using the same account. i cannot use flag also coz wat if the user close the browser then i might not update the flag. do you have any other suggestions
thanks.


PrObLeM wrote:i would have a flag saying in the db 1 being loged in and 0 being not...but this presents a problem...if the person does not logout and close the browser but they try to log back in they wont beable to ...but what you could do is after 30 mins from loggin in the script updates the flag to 0

hopefully this helps...and maybe there is an easyer solution.

[my 100th post w0ot w0ot]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

what you could do:

use sessions/cookies to track down the last page request of a user. And then check at regular times if you should logout the user.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

You do not need any of that :).

As i know (for example i'm using a session system developed by myself which uses MySQL) a session belongs to a user (a userid), so just check if a session exists for that user if returned rows>0 then block him :).

In this way you do not need flags or any other thing.
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

Post by valen53 »

fastfingertips wrote:You do not need any of that :).

As i know (for example i'm using a session system developed by myself which uses MySQL) a session belongs to a user (a userid), so just check if a session exists for that user if returned rows>0 then block him :).

In this way you do not need flags or any other thing.
Regarding the "session system developed by urself", can u make it more clearly ? like concept, or how to do .. cause i also face this kind of problem.
Findus
Forum Newbie
Posts: 7
Joined: Tue Apr 20, 2004 8:47 am

Post by Findus »

You can make your own session handler that uses database instead of files, and thus you can easily track whatever information you want.

Found one tutorial for you: http://www.phpbuilder.com/columns/ying2 ... hp3?page=1

Im pretty sure there is a really good tutorial of this over at the zend site, but i cant find it.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Zend's tutorial is at http://www.zend.com/zend/tut/session.php

It's the easiest way to handle sessions for a "unique login", as you suggest, in the database.

Don't use the IP to verify the uniqueness of a user's session-data, I'd use fastfingertips suggestion of using a numrow-query. The reason for this is that AOL distributes the IPs per HTTP-request - hence an AOL user can have many different IPs during one session.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

patrikG wrote:AOL
:spit:
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

I'm using something that JAM was talking about... Take a look at a basic user online script, modify it to your needs (rewriting is in order) and it should work... I don't have a clear idea, but for my needs it works.. Users can login multiple times on my site, but as JAM said take a basic useronline script and start playing with it..

:)
Post Reply