Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined function session_start()

I'm trying to start a session with php, but I always get this error:

Fatal error: Call to undefined function session_start() in /www/test/test.php on line 2

My Code (Copied form http://php.net/manual/en/session.examples.basic.php):

<?php
session_start();
if (!isset($_SESSION['count'])) {
  $_SESSION['count'] = 0;
} else {
  $_SESSION['count']++;
}
?>

In my php.ini I got extension=session.so . Further, my settings in session section are:

[Session]
session.save_handler = files
session.save_path = "/tmp"
session.use_cookies = 1
;session.cookie_secure =
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = On
session.bug_compat_warn = On
session.referer_check =
session.entropy_length = 0
;session.entropy_file = /dev/urandom
session.entropy_file =
;session.entropy_length = 16
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

I'm using PHP Version 5.4.17. The server is running on an Arduino Yun (Linux).

Anyone can help me, or give ma a hint? :)

Thanks!

like image 771
marius Avatar asked Dec 11 '14 17:12

marius


2 Answers

I had to install additional php7-session package on Alpine Linux to make it work. I guess you can install it too:

opkg install php5-mod-session
like image 102
vladkras Avatar answered Sep 29 '22 23:09

vladkras


On FreeBSD 11:

su pkg install php72-session
service php-fpm restart

my 2 cents

like image 39
Code4R7 Avatar answered Sep 30 '22 01:09

Code4R7