Session start and file uploads
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Session start and file uploads
Session start and file uploads
02-01-2011 3:38 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
PN tells me to use my own web space instead of /tmp (they seem not to have spotted the session problem!). Very helpfully, they refuse to tell me how to do this. Can anyone help?
I have found that both settings can be set in the php.ini file, and I have tried using
session.save_path /temp
upload_tmp_dir /temp
as directives in it. I've placed this php.ini file in the "/" directory of my ccgi directory, with file permissions of "640", and I've created a subdirectory "temp" in that same directory. When I call session_save_path() after the session has been opened, it reports that the session save path is still /tmp.
Do I need to place other parameters in php.ini? Is php.ini being stored in the correct location? And do I need to do anything else in the script that calls session_start()?
Any help would be appreciated.
Re: Session start and file uploads
03-01-2011 2:07 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
You need to use a complete copy of php.ini which you will find in this post. More information about setting session.save_path is given in this topic.
Re: Session start and file uploads
03-01-2011 12:17 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: Session start and file uploads
06-01-2011 3:11 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I'm completely stumped. I've got my directory (.../temp) with permissions of #700, which (I think) should be right. Should they be different? Why is PHP saying that it will use my .../temp file, but then using the system /tmp file?
Re: Session start and file uploads
06-01-2011 7:11 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've never got permission 700 to do anything useful for me to be honest. The lowest I've ever used is 755 but I've been as daring as to go up to 777 in the past although thats not on PN servers which I've never used. Oddly though on my current hosting provider (and the last few) I've never even bothered with permissions. I thought they were only for perl scripts tbh as my php scripts can run with almost anything which is weird when you think that logically they should need permissions like any other process.
Re: Session start and file uploads
07-01-2011 1:10 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
For permissions on ccgi, see the FAQ and links. Your folder will need to be 710. You would either need a copy of the ini file in each subdirectory containing php scripts or (better) a symlink. Or you could use something like this.
Gabe
Re: Session start and file uploads
07-01-2011 3:05 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: okrzynska IF you're using shared hosting no amount of editing your php.ini file will work because it will be in the php root directory - in other words the settings are set by PN web admin. You can't change that unfortunately...
This is not true, you can overwrite our values for most of the php.ini options using a php.ini file in the same directory that your script is in.
See http://uk2.php.net/manual/en/ini.list.php, anything which has PHP_INI_ALL or PHP_INI_PERDIR in the 'Changeable' column can be overwritten in this manner.
Re: Session start and file uploads
08-01-2011 4:14 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Putting it all together, in case it's of use to anyone else, I've ended up doing the following:
a) I copied the full php.ini file (see spraxyt's response) into my top ccgi directory, and also into the directory that contains my scripts (one of these should be a link to the other, rather than a copy, but I'll worry about that later).
b) I placed a short php file that contains the code <?php phpinfo(); ?> into my top cgi directory (eg as a file called phpinfo.php). I ran this by inserting its URL into a browser window, and this gave me a whole load of information about the php environment. I then checked what the full path name was to my cgi directory (where I intended to create a directory to hold my session information and any file uploads). Looking at the value of Loaded Configuration File in the phpinfo window, I took this path (for me, starting /share/storage/) as the full path name to my cgi space.
c) I created a directory (temp in my case) at the top of my cgi space, and gave it permissions of #710.
d) In both of the php.ini copies, I changed the value of upload_tmp_dir and session.save_path to the full path to my cgi space obtained from (b) plus the temp directory name eg if the full path to my cgi space was /share/storage/steve then the full path name used with the variables would be put in the php.ini files as
session.save_path = /share/storage/steve/temp
upload_tmp_dir = /share/storage/steve/temp
to replace the default directives.
e) If your scripts live in more than one directory, you need a copy of php.ini in each directory in which the scripts are held.
This now seems to work, in that I've got one of my scripts to report what the session save path is, and it reports that it is the one I've included in (both of) the php.ini files. No errors have occurred with running out of space.
Thanks again for your solution -- I would never have been able to find one without you!
Re: Session start and file uploads
26-01-2011 12:44 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: Ben
Quote from: okrzynska IF you're using shared hosting no amount of editing your php.ini file will work because it will be in the php root directory - in other words the settings are set by PN web admin. You can't change that unfortunately...
This is not true, you can overwrite our values for most of the php.ini options using a php.ini file in the same directory that your script is in.
See http://uk2.php.net/manual/en/ini.list.php, anything which has PHP_INI_ALL or PHP_INI_PERDIR in the 'Changeable' column can be overwritten in this manner.
I stand corrected! Thanks for the info

Re: Session start and file uploads
29-01-2011 11:31 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
The error messages disappeared now. However, I encountered a new problem.
The user pages that require UserID and password to login are now asking for re-login during the same session when moving from page to page.
I checked and tried different permissions for the temp directory, I checked that the two paths, namely session.save_path and upload_tmp_dir are pointing to the correct temp file, but cannot solve this problem.
I am sure Iam missing some thing here.
I compared the original configuration settings from phpinfo.php with the new settings after the changes: everything is as before, except these two paths.
Any ideas?
Re: Session start and file uploads
30-01-2011 1:24 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: Session start and file uploads
30-01-2011 12:39 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: EricKara The user pages that require UserID and password to login are now asking for re-login during the same session when moving from page to page.
Quote from: spraxyt Have you got a php.ini file (or a link to the root one) in each directory where PHP files reside?
I have all my scrips in a single directory and there is no problem (once logged in, users stay logged in). but several people have mentioned that the php.ini file needs to be in each directory where you have your scripts. If that works for you, I'll try to amend my "solution".
Re: Session start and file uploads
25-02-2011 9:12 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
FWIW I'm looking at a package called XOOPS, it seems popular on Sourceforge
Oh and if the ini file needs to be in EVERY folder then does anyone know the script-fu to search all folders and create a symlink in every one?
Re: Session start and file uploads
26-02-2011 2:57 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
[code=linkphpini.cgi]
#!/bin/bash
echo -e -n "Content-type: text/plain\n\n"
currdir=`pwd`
if [ ! -e ./php.ini ] ; then
echo "./php.ini file not found in $currdir"
exit 1
fi
pipath="$currdir/php.ini"
sessdir=`awk -F "/" '/^[ \t]*session.save_path *=/ \
{ gsub(/[ \t\r\n]/,"",$NF); printf("%s", $NF) }' ./php.ini`
if [ -z "$sessdir" ] ; then
echo "session save directory definition not found in ./php.ini"
exit 2
fi
echo -e "adding links to '$pipath'\ninto directories other than './$sessdir'"
find . -mindepth 1 -type d \( -name "$sessdir" -prune -o -print \) | \
while read i; do echo " $i"; ln -s "$pipath" $i; done
echo "done"[/code]
Store this as, for instance, linkphpini.cgi in the same directory as php.ini. Set permissions to 0700 then run it in your browser. It will create a symlink to php.ini in each subdirectory (except the session directory).
Edit: first sentence revised.
Re: Session start and file uploads
26-02-2011 3:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
#!/bin/bash
echo "Content-type: text/html"
echo
for file in $(find . -mindepth 1 -type d -print0 | xargs -0)
do
[[ $(ls "$file") =~ \.php ]] && ln -s "$(pwd)/php.ini" "$file/php.ini" && echo "$file/php.ini<br>"
done
(again set 0700 and call in browser)
TBH, that's not what I actually do. I use a wrapper to bring the scripts to the ini. It looks more complicated but seems to cut down on maintenance.
Gabe
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Session start and file uploads