Deepmemo logo
hello.

As the PHP manual suggests, sessions should be stored in a different directory than /tmp; threrefore you should change it in your php.ini:

Code:
session.save_path ="6;/usr/local/php5/sessions/"


Once this is done, verify that the directory exists:

Code:
eve:~ nicolas$ ls -ld /usr/local/php5/sessions/
drwxrwxrwx   4 www  www  136 May  7 08:40 /usr/local/php5/sessions/


if it doesn't exist, then create it with the correct permissions for the www user (or whichever user you run apache as) to write in there.
Once this is done, there should be (Entropy's PHP version doesn't have it, bad bad monkey !) a shell called mod_shell.sh in the /usr/local/php5/ext/sessions folder, and since it is not there ... we'll create it. This shell will create the foldertree under your sessions directory according to the depth you specified in the php.ini file (in my example, 6 levels).

here's the mod_files.sh source:

Code:
#! /bin/sh

if test "$2" = ""; then
   echo "usage: $0 basedir depth"
   exit 1
fi

if test "$2" = "0"; then
   exit 0
fi

hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f"
if test "$3" -a "$3" -ge "5"; then
  hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
  if test "$3" -eq "6"; then
    hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
  fi
fi

for i in $hash_chars; do
   newpath="$1/$i"
   mkdir $newpath || exit 1
   sh $0 $newpath `expr $2 - 1` $3
done


copy/paste it to a new file in your sessions directory, chmod it to 755 and run it like so:

Code:
eve:~ nicolas$ sudo ./mod_files.sh /usr/local/php5/sessions/ 6


this will take some time depending on the depth of the foldertree (6 levels is way deep), but once it's done running, you're done.

voilà !

Keywords: php, session

Rating: [ 0 ]
Posted by forrest

You must be logged in to post a comment.