A PHP session follow a simple workflow. Whenever a session is started PHP looks for an existing session by checking PHPSESSID value usually stored in browser cookie or passed in URL depending on the settings in php.ini. If PHPSESSID value is not set then PHP will generate a new session_id and a newRead more
The PHP sessions alone are not secure enough to prevent interception in PHPSESSID by an attacker. Below mentioned measures are also needed to protect the confidentiality of the sessions. o Using HTTPS prevents attackers from accessing PHPSESSID cookie. It is a good practice and makes session more seRead more
Default expiry time for PHP sessions is 1440 seconds. It can be changed by setting session.gc_maxlifetime value which is 1440 by default to some other value you want in php.ini.
session_destroy() destroys all the data for a specific session. If you want to destroy only specific data from a session then you can use unset() function of php which simply unset any key from an array and $_SESSION is also an array.
As per default settings in php.ini sessions are handled using PHPSESSID cookie. And if a user has disabled the cookie then sessions won’t work. If you want to make sessions work even if cookie is disabled then enable session.use_trans_sid in php.ini. Doing so will pass the PHPSESSID in the URL and sRead more
Yes, you can change the path by changing the value of session.save_path in php.ini.
Change session.save_handler value from default files to memcache or memcached in php.ini. Like files memcache and memcached are also internal session save handlers.
By default PHP values for upload_max_filesize and post_max_size are 2M and 8M respectively. To upload a file of more than 2MB you’ll have to change upload_max_filesize value to some bigger value. To upload a file of more than 8 MB you’ll have to change upload_max_filesize and post_max_size both valuRead more
You can use explode function of PHP that converts a string into an array of values. See example given below: $string = "1_2_3_4_5_6_7_8_9_10"; $array = explode("_", $string); $array will be an array containing values from 1 to 10; [1,2,3,4,5,6,7,8,9,10]
By using the implode function of php that converts an array into a string. See example below: $array = [1,2,3,4,5,6,7,8,9,10]; $string = implode((",", $array); $string value will be "1,2,3,4,5,6,7,8,9,10"