# PHP 5.5 Does Not Like Sessions



## LordInateur (Apr 9, 2014)

Hello,

I've freshly installed a FreeBSD 10.0 system with Apache 2.4, Mysql 5.6 and PHP 5.5. I've also installed the PHP extensions port for PHP 5.5. Unfortunately, when I try to test PHP sessions, I get the following error:

```
Fatal error: Call to undefined function session_start() in /usr/local/www/apache24/data/index.php on line 1
```
This has also happened on other pieces of PHP software that works on other servers. This leads me to believe that something is installed wrongly on the machine. However, no amount of Google searching has helped me at all. Any suggestions?

Thanks.


----------



## obsigna (Apr 10, 2014)

CMonster95 said:
			
		

> ...
> Fatal error: Call to undefined function session_start() in /usr/local/www/apache24/data/index.php on line 1
> ...
> Any suggestions?



Did you install www/php55-session?


----------



## LordInateur (Apr 10, 2014)

obsigna said:
			
		

> CMonster95 said:
> 
> 
> 
> ...



Yes, it was a dependency I believe, but just to be sure I reinstalled the port. No dice.

Just for more clarification, my index.php looks like this:


```
<?php session_start(); ?>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <?php
      echo "Hello, World!<br />";
      echo "Current timestamp: ".time();
      echo "Old timestamp: ";
      if(isset($_SESSION['lasttime']) && $_SESSION['lasttime'] != "") {
        echo $_SESSION['lasttime'];
      } else {
        echo "Nope.";
      }
      $_SESSION['lasttime'] = time();
      echo "<br />";
    ?>
  </body>
</html>
```


----------



## obsigna (Apr 10, 2014)

CMonster95 said:
			
		

> obsigna said:
> 
> 
> 
> ...



I assume, you installed php55 with CLI, then please check the output of `echo "<?PHP phpinfo(); ?>" | php | grep session`. You should see a bunch of session related settings, more or less like the following:

```
session
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => On => On
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => On => On
session.entropy_file => /dev/random => /dev/random
session.entropy_length => 16 => 16
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.hash_bits_per_character => 5 => 5
session.hash_function => 1 => 1
session.name => idZ => idZ
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => no value => no value
session.serialize_handler => php => php
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_strict_mode => Off => Off
session.use_trans_sid => 0 => 0
```


----------



## LordInateur (Apr 10, 2014)

The command `echo "<php phpinfo(); ?>" | php | grep session` yields the following:

```
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20121212/soap.so' - /usr/local/lib/php/20121212/soap.so: Undefined symbol "ps_globals" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20121212/wddx.so' - /usr/local/lib/php/20121212/wddx.so: Undefined symbol "ps_globals" in Unknown on line 0
Segmentation fault (core dumped)
```


----------



## obsigna (Apr 10, 2014)

CMonster95 said:
			
		

> The command `echo "<php phpinfo(); ?>" | php | grep session` yields the following:
> 
> ```
> ...
> ...



Segmentation fault means that your php installation got a much bigger problem, than the missing session module.

Perhaps you might want to re-install php completely. First update your /usr/ports directory, then issue the following command as user root:

`portmaster -B -r php55-5.5.11`


----------



## LordInateur (Apr 10, 2014)

Ran portmaster, thanks. I ran the following command:

```
sudo echo "<?php phpinfo(); ?>" | php | grep session
```
I got this as the output:

```
session
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => /dev/urandom => /dev/urandom
session.entropy_length => 32 => 32
session.gc_divisor => 100 => 100
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.hash_bits_per_character => 4 => 4
session.hash_function => 0 => 0
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => no value => no value
session.serialize_handler => php => php
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_strict_mode => Off => Off
session.use_trans_sid => 0 => 0
```
However, the test php file still outputs as follows:

```
Fatal error: Call to undefined function session_start() in /usr/local/www/apache24/data/index.php on line 1
```


----------



## obsigna (Apr 10, 2014)

CMonster95 said:
			
		

> ...
> However, the test php file still outputs as follows:
> 
> ```
> ...



Restart apache!

`service apache24 restart`


----------



## LordInateur (Apr 10, 2014)

obsigna said:
			
		

> CMonster95 said:
> 
> 
> 
> ...



Yeah, I had already done that. But I did it again, just to be sure. Still no dice.


----------



## obsigna (Apr 10, 2014)

CMonster95 said:
			
		

> ... Still no dice.



Show us the output of:

`apachectl -t -D DUMP_MODULES`


----------



## LordInateur (Apr 10, 2014)

obsigna said:
			
		

> Show us the output of:
> 
> `apachectl -t -D DUMP_MODULES`




```
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_prefork_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 php5_module (shared)
```


----------



## obsigna (Apr 11, 2014)

CMonster95 said:
			
		

> obsigna said:
> 
> 
> 
> ...



I'm almost at my wits' end here. Can it be, that the php5_module that is seen by apache comes from a different php installation than the php cli? Please place the following file phpinfo.php into /usr/local/www/apache24/data and point your web browser to it. Can you find the section *Session* on the info page?


```
<?PHP
   phpinfo();
?>
```


----------



## LordInateur (Apr 11, 2014)

How odd. There is no "Session" section, but I do see that Apache is showing that PHP 5.3 is installed instead of PHP 5.5. In the command line, the command "php -i" shows that version 5.5.11 is being used, however.


----------



## obsigna (Apr 11, 2014)

CMonster95 said:
			
		

> How odd. There is no "Session" section, but I do see that Apache is showing that PHP 5.3 is installed instead of PHP 5.5.



Completely remove PHP 5.3 from your system, and then call:

`portmaster -yBD www/mod_php55`


----------



## LordInateur (Apr 11, 2014)

Wonderful! Thank you for your help in solving this, the $_SESSION variables are working now. All is well.


----------

