X

Rate Us :



Share with Friends :

Menu

Configuration settings to work with Sessions :

session.auto_start :

By using this configuration setting, we can start the sessions when the request is starting. The default value is zero. By changing this value as '1', we can start the sessions.


session.save_handler :

By using this configuration setting, we can specify the handler where we want to save sessions.


session.save_path :

By using this configuration setting, we can specify the path location where we want to save sessions.


session.use_cookies :

By using this configuration setting, we can use cookies or not to store the sessions. The default value is '1'. If we change the value to '0', then we can see different session at each refresh.


session.name :

By using this configuration setting, we can change the session_cookie name. The default name is "PHPSESSID"


session.cookie_lifetime :

By using this configuration setting, we can increase or decrease the lifetime of cookie, what we are using to store sessions. The default lifetime is '0' that's why it is creating in-memory cookie. By increasing this value we can create persistence cookie to store the sessions in client system.

Example :

Page1.php :

<?php session_start(); if(isset($_SESSION['out'])) echo "<script>location = 'Page2.php'</script>"; ?>

Page2.php :

<?php session_start(); session_destroy(); setcookie("PHPSESSID", " ", time()-1); echo "Logged out successfully"; ?>


session.ge_maxlifetime :

By using this configuration setting, we can increase or decrease the lifetime to collect the unreferenced sessions by garbage collector. The default value is 1440 sec(24 mins).


$_ENV : (Environment Variable)

By using this, we can get operating system variables.

Example :

<?php print_r($_ENV); ?>

Output :

Array

getenv() :

By using this function, we can get the values of Environment variables.

Example :

<?php echo getenv("Computer name"); ?>

Output :

Window 8

phpinfo() :

By using this function, we can display all super global variables or browser.

Example :

<?php echo getenv("Computer name"); phpinfo(16); ?>

Output :

Display all Environment variables.

ini_get() :

By using this function, we can get a configuration settings value.


ini_set() :

By using this function, we can change the configuration settings value.

Example :

<?php echo ini_get("precision")."\n"; ini_set("precision", 14); echo ini_get("precision"); ?>

Output :

16 14