Hello
I´m new in the community, I'm from México, so english is my second lenguague, so I hope I can explain myself correctly.
I'm having a very extrange problem regarding my login system (with sessions) and overwritting the php.ini to allow upload files larger than 2mb using a form. I red that I can change the upload_max_filesize using .htaccess, ini_set() or by php.ini. The first two option didn´t work out. The .htaccess give a 500 Internal Server Error and the ini_set() did nothing. So I made a php.ini and put the next line:
upload_max_filesize = 8M
I uploaded in my root folder and everything works just fine. I was allowed to upload my file. But then this weird thing happen:
I have a login form that uses sessions. The form is in the file "menu.php" and menu.php and I call this file using include(). So, when the php.ini is in the server, I can´t log-in to my page but just from the pages that are in a diferent directory than the index.php (wiki, admin). In all the other pages and folders, the login system works. If I log-in from the index page and then go to the wiki or admin directory I lost my session. And if I try to log-in from the Wiki page it just do nothing, no error, just the log-in form again. If i delete the php.ini everything works perfectly again.
Summary: I can log-in from all the pages and keep my session but if I go (or try to log-in) to the Wiki folder it appears that I´m not logged-in. The form and the script to log-in is the same in all pages, menu.php in the root folder.
So... is this make any sense? I really need to upload files larger than 2mb and, until now, this is the only way I've managed to do that but obv i need to fix this problem and to know if this thing are even related.
Thank you very much.
Samuel.
upload_max_filesize in php.ini interferes with sessions?
Moderator: General Moderators
Re: upload_max_filesize in php.ini interferes with sessions?
1. You can't use ini_set to change upload_max_filesize. By the time PHP tries to execute that the file has already been uploaded and it's too late.
2. Using .htaccess works provided you have the right server with the right settings.
3. If you make your own php.ini then it will override everything. If you don't put a setting in there then PHP will use the default.
For a .htaccess file, Apache needs to be configured so that you can use .htaccess files. Then you put inside
If you get a 500 error then look in the server error logs for the reason.
If you use a php.ini file then you need to make a copy of the original (phpinfo will tell you where it is) and change the one setting.
2. Using .htaccess works provided you have the right server with the right settings.
3. If you make your own php.ini then it will override everything. If you don't put a setting in there then PHP will use the default.
For a .htaccess file, Apache needs to be configured so that you can use .htaccess files. Then you put inside
Code: Select all
php_value upload_max_filesize 8MIf you use a php.ini file then you need to make a copy of the original (phpinfo will tell you where it is) and change the one setting.
Re: upload_max_filesize in php.ini interferes with sessions?
Hello, tasaires.
Thank you for your reply. I checked the error log when using the .htaccess and i got this:
Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
This means I cannot overwrite the configuration?
I also can´t find the php.ini where it´s supussed to be (usr/lib) Looks like I don´t have permissions.
Thank you
Samuel
Thank you for your reply. I checked the error log when using the .htaccess and i got this:
Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
This means I cannot overwrite the configuration?
I also can´t find the php.ini where it´s supussed to be (usr/lib) Looks like I don´t have permissions.
Thank you
Samuel
Re: upload_max_filesize in php.ini interferes with sessions?
If "php_value" raises an error then the server is set up in a different way than most.
Like I said, phpinfo will tell you where the php.ini file is. If you can't get to it then contact the guy who manages the server and ask him to increase the upload_max_filesize setting.
Like I said, phpinfo will tell you where the php.ini file is. If you can't get to it then contact the guy who manages the server and ask him to increase the upload_max_filesize setting.