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!
well if you want to clear the cookie when they leave or close thier browser, youll need to use javascript. theres not other way
but not everyone has js turned on
if you dont set an expires value(default session behavior) the browser will clear the cookie when they close the browser.
if you want the both the browser to clear the cookie AND timeout the session after a period of inactivity(whichever comes first), you need to do the timeout yourself.
for example, everytime they request a page from your website you update a session or database last activity value.
then, you check that value every page request. if the last time they were active was more than x minutes ago, then you stop accepting the session and start a new one, maybe making them log in again or whatever.