Cookies are very important for dynamic websites. They allow you to set parameters for user interaction. With cookies, your website can remember visitors and show them appropriate data, ads, and even specific pages. By default, cookies only last for a single browser session. With the CookieExpires Apache directive, you can set the length of time.
With a dedicated server, you can put the directive into your Apache configuration file, but this is not an ideal setup because it will control cookies for all websites on the server. The better method is to use an .htaccess file for each site.
Add the directive to your .htaccess file or create a new file:
Replace “expiry-period” with the number of seconds (i.e. 432,000 for 5 days) or you can insert as follows:
CookieExpires 2 weeks 3 days 7 hours