Is there a way I can piggy back sessions to know if the user is online?
I.e: use logs on, I set a $_SESSION variable, user times out- cookie Garbage collector update
Depends on your situation, it may be better for you to create a separate table "whose-online" with the columns: "ip" and "last-updated-time" and query/update this table every time a user loads a page.
On page load queries may include:
Benefits of using this technique:
Note: If you use this you should want to take into consideration that any pageview will create a row in your table so based on useragent you can disregard bots or only count the popular ones (Firefox, IE, Safari, Opera, etc).