Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-10-2007, 02:26 AM   #1
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
Question setting cookie expiration date in php

I have tried to set a cookie that can last for 6 months on users' computers one they log in to the system using:

PHP Code:
$_SESSION["loginUsername"] = $user;
$inSixMonths 60 60 24 180 time(); 
setcookie('lastVisit'date("G:i - m/d/y"), $inSixMonths); 

I don't want users to log in to my website whenever they restart their browser or even their computers, although, I know it is a security risk.

For some reason, when I'm logged in to the system and don't have any activities for a while, all session variables expire so that I have to log in again.

I have found some tricks to increase session's time out value by modifying php.ini, but I'm just wondering if it's possible to do that using php codes, since I don't have access to php.ini ?

Thanks in advance
Old 08-10-2007, 08:30 AM   #2
Registered: Dec 2005
Distribution: RedHat, Ubuntu
Posts: 101

Rep: Reputation: 15
the second arg to setcookie() is a time_t integer. Just put your $inSixMonths var in there; don't use date() to convert. ref:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Moglen: SUSE Vouchers Have No Expiration Date! (Unlike MS's Patent Bullying) LXer Syndicated Linux News 0 05-20-2007 01:01 PM
PHP : Online quiz cache control and page expiration devansh LQ Suggestions & Feedback 1 09-17-2004 01:37 PM
/etc/shadow expiration date liguorir Linux - Software 1 05-04-2004 02:42 PM
cookie expiration date in IE6 icepig Programming 2 11-17-2003 01:42 PM
Setting up Passwd expiration details deepika Linux - Newbie 1 07-17-2003 04:28 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration