Function Reference/set transient
Description
Set/update the value of a transient
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
Usage
<?php set_transient( $transient, $value, $expiration ); ?>
Parameters
- $transient
- (string) (required) Transient name. Expected to not be SQL-escaped. Should be 45 characters or less in length.
- Default: None
- $value
- (mixed) (required) Transient value. Expected to not be SQL-escaped.
- Default: None
- $expiration
- (int) (optional) Time until expiration in seconds from now. Ex: For one day, the expiration value would be: ( 60 * 60 * 24 ).
- Default: 0.
Return Values
- (boolean)
- False if value was not set and true if value was set.
Examples
Notes
Change Log
Since: 2.8
Source File
set_transient() is located in wp-includes/functions.php.
Related
Transients API:
set_transient(),
get_transient(),
delete_transient(),
set_site_transient(),
get_site_transient(),
delete_site_transient()