Q:

PHPUnit with Selenium2 - share session not working

I'm doing some tests with PHPUnit and Selenium and i would like all of them to run in the same browser window. 
I've tried starting the Selenium Server with 
java -jar c:\php\selenium-server-standalone-2.33.0.jar -browserSessionReuse

but with no visible change. 
I've also tried with shareSession() in the setup
public function setUp()
{
    $this->setHost('localhost');
    $this->setPort(4444);
    $this->setBrowser('firefox');
    $this->shareSession(true);
    $this->setBrowserUrl('http://localhost/project');
}

but the only change is that it opens a window for every test, and not really sharing the session.  I'm out of ideas at this point. 
My tests look like this:
public function testHasLoginForm()
{
    $this->url('');

    $email = $this->byName('email');
    $password = $this->byName('password');

    $this->assertEquals('', $email->value());
    $this->assertEquals('', $password->value());
}

A:

Here's the elegant solution.   To share browser sessions in Selenium2TestCase, you must set sessionStrategy => 'shared' in your initial browser setup:
public static $browsers = array(
    array(
        '...
        'browserName' => 'iexplorer',
        'sessionStrategy' => 'shared',
        ...
    )
);

The alternative (default) is 'isolated'. 

A:

You do not need to use the flag -browserSessionReuse
In your case The set up function running before every test and starting new instance. 
This is what i did to prevent this to happen (Its little bit ugly but work for me both in Windows and Ubuntu):

I created helper class with static ver: $first and initialized it. 
helper.php:
<? php
class helper
{
    public static $first;
}
helper::$first = 0;
? >

Edit main test file setUp() function(and add require_once to helper.php):
require_once "helper.php";

class mySeleniumTest extends PHPUnit_Extensions_SeleniumTestCase
{

        public function setUp()
        {
                $this->setHost('localhost');
                $this->setPort(4444);
                if (helper::$first == 0 )
                {
                        $this->shareSession(TRUE);
                        $this->setBrowser('firefox');
                        $this->setBrowserUrl('http://localhost/project');
                        helper::$first = 1 ;
                }
        }
....

setHost and setPort outside the if because the values restarted after each test(For me...) and need to set up every time (if the selenium server is not localhost:4444)

