Jump to content

$_SESSIONS and $_FILES not working anymore on shared server


gerarddd

Recommended Posts

After a cleanup of old files on my shared server, suddenly $_SESSION and $_FILES aren't working anymore.

I think it has to do with problems of saving these on the server. My hosting company told me that I have no access of the folder where sessions are stored so I couldn't have deleted it by accident.

 

It's not a problem of my software I think,  it has always worked well and a very simple php-file to check if sessions are working or not, gives a problem on this domain (variables are not saved) and not on my others.

As I check phpinfo, the session.save_path is standard /tmp 

 

Please, someone have an idea how I can solve this?

 

With regards,

Gerard

Link to comment
Share on other sites

^^^ and tell use what exact symptom or error you get that leads you to believe these 'aren't working' and do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would help you by reporting and displaying all the errors it detects?

 

some possibilities - your files either got altered and now have a BOM character saved with them or a .htaccess file or local php.ini file got deleted that was setting some php settings (output_buffering, upload size settings) that are now no longer in effect and are preventing your code from 'working'.

Link to comment
Share on other sites

Thank you for responding. This is the first time this problem happens to me and I'm desparate... 
And the problem is on all sub-domains of this domain. 
 
I used a simple testfile to be sure it's not a problem of my programming: 
 
if(!isset($_GET['reload']) OR $_GET['reload'] != 'true') {
   // Set the message
   $_SESSION['MESSAGE'] = 'Session support enabled!<br />';
   // Give user link to check
   echo '<a href="?reload=true">Click HERE</a> to check for PHP Session Support.<br />';
} else {
   // Check if the message has been carried on in the reload
   if(isset($_SESSION['MESSAGE'])) {
      echo $_SESSION['MESSAGE'];
   } else {
      echo 'Sorry, it appears session support is not enabled, or you PHP version is to old. <a href="?reload=false">Click HERE</a> to go back.<br />';
   }

 

}
 
Result: session support is not enabled. 
And these warnings....
 

Warning: Unknown: open(/tmp/sess_4c8l5nmagramkrjb5tmtgt6135, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

 

I'm using PHP 5.4 through a phpselector in direct admin. 

 

And I did not put something special in my .htaccess file:

 

Options +FollowSymLinks
RewriteEngine On
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Link to comment
Share on other sites

You said your hoster doesn't allow you to access the /tmp folder directly. Have you considered using a save path which you do have access to? It would make things a lot easier, because you could actually see what's going on.

 

Otherwise, this looks like you need to contact support. I don't see how we could fix your server configuration problems from here, especially when you don't even have sufficient permissions.

Link to comment
Share on other sites

You are right. I'm just starting experimenting with the command ini_set('session.save_path', path)

I created a folder and added it in my little test file and it worked!!

It's a new thing for me. Must I use this only once before a session is declared or every time before a session_start ?

 

Is there also something like this where temporarily $_FILES are stored?

 
P.S. I will recontact with my support to see what happened with the original /tmp.
Link to comment
Share on other sites

It's a new thing for me. Must I use this only once before a session is declared or every time before a session_start ?

 

You'd have to do it every single time, which is why you should set up a proper PHP configuration file instead of messing with the settings at runtime.

 

 

 

Is there also something like this where temporarily $_FILES are stored?

 

See the manual.

Link to comment
Share on other sites

1 - I don't see where you started the session in your code.

2 - In what way is the existence or even the value of your GET variable related to the existence of session support?  The beginning of your code is creating a session variable and assigning a value based simply on whether the 'reload' parm is present and is set to 'true'. How is this getting presented to the script?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.