session_set_cookie_params() Expiry Time

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
Plxply
Forum Newbie
Posts: 14
Joined: Sat Dec 19, 2009 2:40 pm

session_set_cookie_params() Expiry Time

Post by Plxply »

Hello,

I currently have a very basic site which I have made containing a simple login system and registration system with the user information stored within a session once they've logged in. At the moment I have:

Code: Select all

session_set_cookie_params(strtotime('+1 week') - time());
At the top of every page, however I want to have an area where the user can specify how long they want to have the cookie stored on their system. Would I be able to change the cookie when the user logs in, and have it stay with that expiry time even though that command and session_start() is passed at the top of every page?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: session_set_cookie_params() Expiry Time

Post by Eran »

You can recreate the cookie if you want to change the expiry date for an existing cookie.
Post Reply