php sessions

I wrote a program and one person keeps getting this when the session is created. The session is created with 0 bytes.

[25-Jul-2015 03:30:15 UTC] PHP Warning:  session_start(): open(/tmp/sess_6b706f1ff59acce6c3fa7f27a91a9dc6, O_RDWR) failed: Permission denied (13) in /home/vmp662980/public_html/settings.php on line 0

<?php
session_start();
?>

The code above will produce this for my user. He is running Windows 7 with IE 11. I am unable to duplicate the issue. Any advise.
LVL 7
Robert SaylorSenior DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The usual reason is that the directory where the session data is supposed to be stored is not writeable by PHP and the web server.  He may be on Win 7 but "/home/vmp662980/public_html/settings.php" looks like a Linux home directory path.  ??
Robert SaylorSenior DeveloperAuthor Commented:
/tmp is set to 777 and from Windows 8.1 IE 11 it works, Mac with Firefox it works.
Ray PaseurCommented:
Here is how to use PHP sessions.  It's usually very simple, and this symptom sounds like you're using them right, but there may be some confusion about the file paths, which are (unfortunately) configuration variables.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11909-PHP-Sessions-Simpler-Than-You-May-Think.html

Please run this script on the failing machine and show us the output, thanks.
<?php // demo/temp_rsaylor.php

/**
 * http://www.experts-exchange.com/questions/28700138/php-sessions.html
 */
ob_start();
error_reporting(E_ALL);
echo '<pre>';
clearstatcache(TRUE);

$cwd = getcwd();
var_dump($cwd);
var_dump(getFilePerms($cwd));
echo PHP_EOL;

$pth = session_save_path();
var_dump($pth);
var_dump(getFilePerms($pth));
echo PHP_EOL;

function getFilePerms($path)
{
    $perms = fileperms($path);

    if (($perms & 0xC000) == 0xC000) {
        // Socket
        $info = 's';
    } elseif (($perms & 0xA000) == 0xA000) {
        // Symbolic Link
        $info = 'l';
    } elseif (($perms & 0x8000) == 0x8000) {
        // Regular
        $info = '-';
    } elseif (($perms & 0x6000) == 0x6000) {
        // Block special
        $info = 'b';
    } elseif (($perms & 0x4000) == 0x4000) {
        // Directory
        $info = 'd';
    } elseif (($perms & 0x2000) == 0x2000) {
        // Character special
        $info = 'c';
    } elseif (($perms & 0x1000) == 0x1000) {
        // FIFO pipe
        $info = 'p';
    } else {
        // Unknown
        $info = 'u';
    }

    // Owner
    $info .= (($perms & 0x0100) ? 'r' : '-');
    $info .= (($perms & 0x0080) ? 'w' : '-');
    $info .= (($perms & 0x0040) ?
                (($perms & 0x0800) ? 's' : 'x' ) :
                (($perms & 0x0800) ? 'S' : '-'));

    // Group
    $info .= (($perms & 0x0020) ? 'r' : '-');
    $info .= (($perms & 0x0010) ? 'w' : '-');
    $info .= (($perms & 0x0008) ?
                (($perms & 0x0400) ? 's' : 'x' ) :
                (($perms & 0x0400) ? 'S' : '-'));

    // World
    $info .= (($perms & 0x0004) ? 'r' : '-');
    $info .= (($perms & 0x0002) ? 'w' : '-');
    $info .= (($perms & 0x0001) ?
                (($perms & 0x0200) ? 't' : 'x' ) :
                (($perms & 0x0200) ? 'T' : '-'));

    return $info;
}

Open in new window

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Dave BaldwinFixer of ProblemsCommented:
See if your "Windows 7 with IE 11" user has cookies turned off or is doing In Private browsing or something like that.  If it is unique to that user, it is probably something they have done.  I have two Win7 machines with IE11 that do not have any problems with sessions.  Along with numerous XP, Mac, and Linux machines.
Robert SaylorSenior DeveloperAuthor Commented:
Ray,

Not sure why but we found:

the user goes to www.domain.com and logs in.

They then goto test.domain.com and logs in but the session is confusing test.domain.com with www.domain.com for the session. We resolved this by creating a new domain for the backend admin so testing that currently.
Dave BaldwinFixer of ProblemsCommented:
The cookie that is set with the session_id is for a particular domain and 'www.domain.com' and 'test.domain.com' are not the same.  That could easily cause the error that you are seeing.  See 'domain' on this page: http://php.net/manual/en/function.session-set-cookie-params.php  To get the same session on all subdomains, you need to alter the cookie's domain.
Cookie domain, for example 'www.php.net'. To make cookies visible on all subdomains then the domain must be prefixed with a dot like '.php.net'.
You can use http://php.net/manual/en/function.session-get-cookie-params.php to get the cookie info first.

PS: 'domain.com' is the domain.  Both www.domain.com and test.domain.com are subdomains.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Maybe this slipped by earlier, so I'll post the link to it again.
http://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html
Robert SaylorSenior DeveloperAuthor Commented:
With only some browsers and even with IE 11 some machines would fail when we logged into www.domain1.com then logged into test.domain1.com

We fixed this by creating www.anewdomain.com to log into then from their the user can log into test.domain1.com and the issue has resolved. I am pretty positive this was a cross domain cookie/session issue and then I add in iframes and it gets nasty. All is ok now.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.