PHP Session Issues


#1

Hello. I just joined DreamHost today and I’ve been reading all the posts about the downtimes, etc and I’m pretty scared. Plus this forum keeps failing >=(. Well anyways, I’m moving some websites from my own server, which I’m planning to no longer use, to DreamHost’s servers. I uploaded 2 sites and they seam to work fine – expect for one thing. Both sites use Sessions to let the user login. However, sessions don’t seam to work properly on DreamHost’s server. =(. I’m using PHP 5 by the way, my apps need it. Can some one help me?

By the way, if you want to see the issue, go here:
http://kasra.dreamhosters.com/pmd/index.php
and try to login with:
username: testing
password: testing

You will see the $_SESSION keys and values at the top of the page. (it’s always empty, hence you just see Array ( ) )

So can someone help?


#2

Never mind. The issue was that you can’t just do:

$_SESSION = $some_array;

You have to do this:

foreach($some_array as $key=>$value){
$_SESSION[$key] = $value;
}


#3

[quote]foreach($some_array as $key=>$value){
$_SESSION[$key] = $value;
}[/quote]
Or your could just use print_r:<? print "<!-- $_SESSION= "; print_r($_SESSION); print "-->" ?>…which’d slot the $_SESSION array into your HTML comments that’re just a “View --> Source” away.