php会话ID不匹配

session id is not unique between 1.php and 2.php.

1.php basically sets $_SESSION['var'] = "hello"

and 2.php: print_r($_SESSION['var'])

echoing out session_id() shows different id. same browser (firefox).

everything was working fine, until I screwed up the .htaccess. I deleted .htaccess and restarted apache2.

It sounds like you most likely need to set the session.save_path for PHP.

PHP: session_ save_ path reference

Sessions on PHP have always caused issues for me, these days I have moved onto the Zend Framework which has a Zend_Session component that takes care of most of the issues for me and I have to do less thinking. Take a look and see if that would work for you as well!

take a look at PHP session id's differ

--edit--

"everything was working file...until you messesd up with .htaccess" : it means you had some kind of internal redirection setup in there. Take a look at http://enarion.net/web/apache/htaccess/redirect-www-and-no-www/

You use $var variable somewhere in your code either on 1.php or on 2.php Try to change the $var to $some_thing_else

When you use $_SESSION this is common problem.