1

I have couple questions regarding the sessions ...

1) How can I list all active sessions on my server?

2) How can I make secure login, account timeout and logout using sessions?

1 Answer 1

1

PHP's default session handler saves the session data as a serialize() copy of the $_SESSION array, and that goes into a file, which is specified in php.ini. You can retrieve it at runtime with session_save_path(). Generally, the files are constructed as

$sessionFile = 'sess_' . session_id();

Listing all sessions is just a matter of pulling out all the files in the session dir that start with sess_. However, unless you're doing long-running processes, most sessions will only be 'active' for the short time someone's actually hitting a page on your site.

As for the login system, there's tons of answers on this site. Look at the "Related" links on the right-hand side of this page to find some.

Sign up to request clarification or add additional context in comments.

6 Comments

@Marc B: can you explain more about the session list? I`m running my own server (localhost) on which I can access from any PC over the LAN. I want to show the session of each access.
each access? You mean look in the server's access log?
usually when I access a website, a session is created for my access. I want to preview this (as admin) on my localhost/testing server.
PHP doesn't create sessions automatically unless it's configured to do so. session.auto_start in php.ini, or via session_start() calls in your code.
OK, I use session_start() what can I do as admin page that lists all the sessions and delete the ones I don`t want them to be connected?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.