473,412 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Who's signed in

Anyone know a good way to check if someone is signed in, has a session
going, etc.? I could have a signed in field that updates from 'yes' to 'no'
when they sign out, but that wouldn't work well when the session times out
or they just close the browser. Thx.
Steve.
Jul 17 '05 #1
3 1962

"szar" <no**@nowhere.net> wrote in message
news:Di***************@newssvr22.news.prodigy.com. ..
Anyone know a good way to check if someone is signed in, has a session
going, etc.? I could have a signed in field that updates from 'yes' to 'no' when they sign out, but that wouldn't work well when the session times out
or they just close the browser. Thx.
Steve.


BTW, I do have access to cron jobs but nothing else on the server.
Steve.
Jul 17 '05 #2
szar wrote:

"szar" <no**@nowhere.net> wrote in message
news:Di***************@newssvr22.news.prodigy.com. ..
Anyone know a good way to check if someone is signed in, has a session
going, etc.? I could have a signed in field that updates from 'yes' to

'no'
when they sign out, but that wouldn't work well when the session times
out or they just close the browser. Thx.
Steve.


BTW, I do have access to cron jobs but nothing else on the server.
Steve.


Hi Steve,

Two solutions,

1) using the filesystemstorage and session.gc_probability
(I don't recommend this)

If you work with sessionstorage on the filesystem (session.save_handler =
files), you could try this:
(It is a bit ugly)
When you create your session, store the name of the sessionfile (often
stored in temp-directory, check your php.ini session.save_path = /tmp) in
some databasetable accompanied with the username.
Check every X minutes the if the filenames stored in the database are still
in the tempdirectory.
If not delete them from your table.

To make this a little more reliable you might consider to change the value
of session.gc_probability to a much higher value (100), but this means of
course your garbagecollection of stale sessionfiles will run every times.

from php.ini
; Percentual probability that the 'garbage collection' process is started
; on every session initialization.
session.gc_probability = 1

2) Build it yourself
Maybe a better approach would be to:
a) store in a db-table the phpsessid with a username and a timestamp.
b) every time you do something in the session, update the timestamp in the
db for this user.
c) when you need the 'online visitors', just delete old records from the
table, and what is left are possible online users.

I think the second approach is better.

Good luck,
Regards,

Erwin Moller

PS: In Java we have this beautifull HttpSessionBindingListener, but I am not
aware of similar functionality in PHP.
Jul 17 '05 #3
I use a session variable to hold the users login name - if that var
isn't == "" then someone has signed in - to see who, I just read the
session var.

To determine if they are still online I use a MySQL table called
online and on every web page I make a call to update that table with a
timestamp - each user has a record in the online table so I can tell
who is online based on the timestamp - I use 10 minutes - if the
timestamp is within 10 minutes of now() then I assume they are still
online.

On Thu, 23 Oct 2003 06:11:47 GMT, "szar" <no**@nowhere.net> wrote:
Anyone know a good way to check if someone is signed in, has a session
going, etc.? I could have a signed in field that updates from 'yes' to 'no'
when they sign out, but that wouldn't work well when the session times out
or they just close the browser. Thx.
Steve.


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: MiniDisc_2k2 | last post by:
Okay, here's a question about the standard. What does it say about unsigned/signed mismatches in a comparison statement: char a = 3; unsigned char b = 255; if (a<b) Now what's the real...
8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
14
by: Salad | last post by:
I've always thought that the talking heads, the people that write Access mags, the "gurus" that tout themselves as being the true masters of Access tell MS what they want. How does a lowly...
17
by: Christopher Dyken | last post by:
Hi group, I'm trying to implement two routines to handle 32x32-bits and 64x64-bits signed integer multiplication on a 32 bits machine in C. It easy to find descriptions of non-signed...
9
by: dam_fool_2003 | last post by:
For int data type the default range starts from signed to unsigned. If we don't want negative value we can force an unsigned value. The same goes for long also. But I don't understand why we have...
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
10
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
6
by: Kislay | last post by:
Consider the following code snippet unsigned int i=10; int j= - 2; // minus 2 if(i>j) cout<<"i is greater"; else cout<<"j is greater"; Since i is unsigned , j is greater . I know why , but...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.