php sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manjit.kool007
Forum Newbie
Posts: 4
Joined: Mon Aug 27, 2007 10:04 am

php sessions

Post by manjit.kool007 »

hi,
i have pages in which users logins using sessions.
I want to see all the session that have been created using a function or code.. can any one help me?
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

Code: Select all

print_r($_SESSION);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There is no one function that can show you all the sessions currently active.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Actually there is a way. You have to create your own session handler and store the sessions in your own directory or a database. Then you can easily view the active sessions and session data.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Maybe it can be done by using the session storage ...


E.g.

Code: Select all

ls /tmp/sess_*
will return all active sessions stored as sess_* where * is for session ID.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Those aren't guaranteed active but potentially active.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

AKA Panama Jack: 1 minute earlier ;)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

feyd wrote:Those aren't guaranteed active but potentially active.
What is the difference from server-side view?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If they are stale, PHP will not use them. Plus, you could potentially have multiple server sessions in there (in a shared host environment.) This is why database sessions are preferred.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

VladSun wrote:Maybe it can be done by using the session storage ...

E.g.
Just an example - it's not supposed to cover all of the storage methods ... I've never said use file-based session storage instead of DB-based session storage ...

I posted it in contrast of your answer
feyd wrote:There is no one function that can show you all the sessions currently active.
to the question
manjit.kool007 wrote:I want to see all the session that have been created using a function or code.. can any one help me?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

feyd wrote:Those aren't guaranteed active but potentially active.
And that was ambiguous - I understood it as you didn't agree neither with me, neither with AKA Panama Jack ...
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply