php5, sessions not working

I'm getting
Code:
Call to undefined function session_name().
I have installed the package www/php5-session and in my extensions.ini it says
Code:
extension=session.so
But I still get that error, even after restart. Can someone tell me what's wrong?
 
Usually /usr/ports/UPDATING is meant. But you can also have a look at FreshPorts: http://www.freshports.org/lang/php5/.

Back to your problem:
Its very likely, that the session module is not loaded. If you are working on a console, check the ouptut of:
Code:
$ php -m
If you use PHP as Webservice, create a file with the following content and check its output:
Code:
<?php
phpinfo();

In both cases you must see an entry "session". If it do not occurs, your extension is not loaded.
 
Thorny said:
Usually /usr/ports/UPDATING is meant. But you can also have a look at FreshPorts: http://www.freshports.org/lang/php5/.

Back to your problem:
Its very likely, that the session module is not loaded. If you are working on a console, check the ouptut of:
Code:
$ php -m
If you use PHP as Webservice, create a file with the following content and check its output:
Code:
<?php
phpinfo();

In both cases you must see an entry "session". If it do not occurs, your extension is not loaded.


Correct, the module doesn't look like it's loading. But why would it not load if I have extension=session.so? Is there an error log somewhere?
 
MJennings said:
Correct, the module doesn't look like it's loading. But why would it not load if I have extension=session.so? Is there an error log somewhere?

Hm, you installed PHP via ports, right? First check if the additional ini-file, which contains "extension=session.so", is loaded. Try:
Code:
$ php -i | grep extension

The output should look like this:
Code:
additional .ini files parsed => /usr/local/etc/php/extensions.ini
extension_dir => /usr/local/lib/php/20060613 => /usr/local/lib/php/20060613

The path to the additional .ini file may vary, but it's the default of the ports. Check the content of the given file. If it's look like the following, the error is not there:
Code:
$ cat /usr/local/etc/php/extensions.ini 
extension=bbcode.so
extension=gettext.so
extension=calendar.so
extension=ctype.so
extension=bz2.so
[B]extension=session.so[/B]
[more]

After that check the content of the extension-dir; it should look like that:
Code:
$ ls -lah /usr/local/lib/php/20060613
total 4328
drwxr-xr-x  2 root  wheel   1.0K Oct  7 22:35 .
drwxr-xr-x  4 root  wheel   512B Oct  7 21:51 ..
-r--r--r--  1 root  wheel    79K Dec  7  2009 bbcode.so
-r--r--r--  1 root  wheel    43K Oct  7 22:02 bcmath.so
-r--r--r--  1 root  wheel    32K Oct  7 21:54 bz2.so
-r--r--r--  1 root  wheel    38K Oct  7 21:53 calendar.so
-r--r--r--  1 root  wheel    20K Oct  7 21:53 ctype.so
-r--r--r--  1 root  wheel    69K Oct  7 22:28 curl.so
-r--r--r--  1 root  wheel   215K Oct  7 22:14 dom.so
-r--r--r--  1 root  wheel   391K Oct  7 22:35 gd.so
-r--r--r--  1 root  wheel    17K Oct  7 21:52 gettext.so
-r--r--r--  1 root  wheel    45K Oct  7 21:57 iconv.so
-r--r--r--  1 root  wheel   2.0M Oct  7 22:16 mbstring.so
-r--r--r--  1 root  wheel    44K Oct  7 21:57 mcrypt.so
-r--r--r--  1 root  wheel    15K Oct  7 22:01 mhash.so
-r--r--r--  1 root  wheel    63K Oct  7 22:13 mysql.so
-r--r--r--  1 root  wheel    25K Oct  7 22:03 pcntl.so
-r--r--r--  1 root  wheel    40K Oct  7 22:00 pcre.so
-r--r--r--  1 root  wheel   114K Oct  7 21:58 pdo.so
-r--r--r--  1 root  wheel    36K Oct  7 22:03 pdo_mysql.so
-r--r--r--  1 root  wheel    37K Oct  7 22:04 pdo_pgsql.so
-r--r--r--  1 root  wheel   119K Oct  7 21:56 pgsql.so
-r--r--r--  1 root  wheel    32K Oct  7 21:59 posix.so
[B]-r--r--r--  1 root  wheel    70K Oct  7 21:55 session.so[/B]
-r--r--r--  1 root  wheel    14K Oct  7 21:58 shmop.so
[more]

If there is an correct entry in the ini-file and if the session.so file exists in the correct extension dir, have a look in the http-error log. It depends on you Server, where to find the log.
 
Back
Top