how to kill the session cookie after a period of time in php


if I define the session.cookie_lifetime to be zero so the cookie will only be killed after the browser is closed. but if I want to sent a max time which after that even if the browser was not closed the session will end anyway???? integer




This makes the cookie to be expired in one hour.

setcookie("TestCookie", $value, time()+3600);

More about setting cookie is at here.




Assign value forsession.cookie_lifetime in PHP ini file.

session.cookie_lifetime=300 for 5 mins




Normal Cookie From The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

That will give a nice long cookie.

Session Based Cookie link [] For Session cookies use an int in seconds [360 = 6mins or 21600 = 6hours]

Also, for the session() cookie type make sure to add it before you start the session


People are also looking for solutions to the problem: php - load data local infile user provided VALUES


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.