GoAdmio Command Line: sessiongcmaxlifetime with /go/sessiongcmaxlifetime

session.gc_maxlifetime is the number of seconds PHP waits after a session was last used before its data counts as garbage and can be deleted. Visitors whose session is deleted are logged out. PHP's own default is 1440 (24 minutes), which is short for sites with logins. /go/sessiongcmaxlifetime changes this one setting in every php.ini file on the server (all installed PHP versions) with a single command. It can: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Set 8 hours (the default value)
/go/sessiongcmaxlifetime

# Set one day
/go/sessiongcmaxlifetime 86400

# Show the current value
/go/sessiongcmaxlifetime return

Arguments

Argument Required Default Notes
seconds No 28800 The new value, in seconds.
return No — Print the current value and change nothing. Case-insensitive.
You pass Result
Nothing Sets 28800 (8 hours).
An option starting with -- Ignored. Sets 28800.
A number, such as 86400 Sets that number.
return, Return, or RETURN Prints the current value.
More than one word All the words are joined with spaces and written as the value.

[!WARNING]
The value is not checked. Text, a negative number, or several arguments are all written to php.ini as they are, which can leave PHP with an invalid setting. Pass a single whole number.

Common values

Seconds Length
1440 24 minutes (PHP’s own default)
3600 1 hour
28800 8 hours (this command’s default)
86400 1 day
604800 7 days

Examples

# Keep sessions for 8 hours on every PHP version
/go/sessiongcmaxlifetime

# Keep sessions for one day
/go/sessiongcmaxlifetime 86400

# Read the current value into a script variable
Value=$(/go/sessiongcmaxlifetime return)
echo "$Value"

# Review recent calls
tail /var/log/go/sessiongcmaxlifetime.log

Output

Setting a value

session.gc_maxlifetime updated successfully.

This line is printed even if no php.ini file was found or changed. It does not mean the setting was verified.

Reading the value

28800

Only the number is printed. See How return works.

Unknown operating system

Unknown operating system.

Nothing is changed.

See the full reference at /go/sessiongcmaxlifetime and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *