Yes, that how you should set the session path. Of course, the "/var/www/sessions" folder has to be writable and when you check it there should be session files created by PHP.
Also, you said that you have changed the session expiration but I see that you are still using $cookieParams["lifetime"] instead of an actual number of seconds for which session cookie should be valid (like 86400 if you want the session to be active for 24 hours).
When you have things like this, you should not be logged out randomly for sure.
One other thing that can cause you problems is if you have LOGIN_FINGERPRINT set to true in your ASConfig.php file. When this value is set to true, AS will create a "fingerprint" which consists of your IP address and your browser information and check it whenever you call the ASLogin::isLoggedIn() method. The purpose of this is to prevent people who somehow stole your session cookie to continue using the app.
However, if your IP changes frequently, you will often be logged out and your session will be invalidated. So, if that's the issue in your case, then you will need to set this parameter to false so you can use the app properly.
- Milos