hi all,
iam sureesh, iam doing a online project in php, i want know how we can use sessions in php.......
how to make session end when the user click the logout button

Recommended Answers

All 3 Replies

Sessions expire automatically, I don't think you can force a session to expire. The time limit for a session is set by the session.cache_expire directive. You should be able to set this directive at the beginning of your script using the ini_set function. That way you determine how long the session will last. I think normally a session will expire after 3 minutes.

Sessions expire automatically, I don't think you can force a session to expire. The time limit for a session is set by the session.cache_expire directive. You should be able to set this directive at the beginning of your script using the ini_set function. That way you determine how long the session will last. I think normally a session will expire after 3 minutes.

Thank you for ur response

Actually, you can effectively end a session using:

session_unset();
session_destroy();

Alternatively, you may find my PHP session class helpful.
http://www.troywolf.com/articles/php/class_session/
NOTE: my session class does not use PHP's built-in sessions. The class comes with methods and code examples to do login and logout. The purpose of my class is to have complete control over session timeout. I write web apps that need to work like normal business data-entry apps. Users expect to login and STAY logged in all day--no session expirations. My class lets you do this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.