5

PHP 中确定是否在服务器的 php.ini 文件中启用会话的最简单方法是什么。我正在为我的 PHP 应用程序进行安装前检查,只需要检查一下。

4

3 回答 3

6
if (!extension_loaded('session')) {
    die('You must enable PHP session support for the system to work.');
}
于 2012-08-01T21:26:25.367 回答
0

您可以编写一个快速脚本:

<?php

// page1.php
session_start();
$_SESSION['my_index'] = "IT WORKED!";

然后,在另一个页面上:

<?php
// page2.php
session_start();
echo $_SESSION['my_index'];

//output: IT WORKED
于 2012-08-01T21:23:21.713 回答
0
if ( ! function_exists('session_start')) die;
于 2012-08-01T21:28:24.937 回答