Jump to content

[SOLVED] Session problem


SoundreameR

Recommended Posts

I'm making an oop site on PHP 5/Apache 2/WinXP. I tested the session system of php with a simple script to start a session and firstly echo that this is a new session and then set a $_SESSION["used"] variable to something that the next time the page opens it indicates that this variable is set to something and this session is old. Ok. It works. But when i start a session in my new site's scripts the session is registered, there is a session file, there is a session cookie (PHPSESSID), the session opens with the same ID every time I run the script, but I can't set any data in $_SESSION. I even tried this:

$_SESSION["BLA"] = "MU"; 
print_r($_SESSION);

And it output Array ( ) !!!  ??? >:(:o :-\ Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/58629-solved-session-problem/
Share on other sites

thats what hes/shes pointing out^^^

even if he initialize that still no work mmmmm no need for start

 

I could see no mention that this had been added!!!

 

I've never used PHP & MySQL installed on a local machine so I have no idea how it works compared to live web space - sorry I can't help here :(

Have you added session_start(); at the start of the code?

 

$_SESSION["BLA"] = "MU";

print_r($_SESSION);

 

thats what hes/shes pointing out^^^

even if he initialize that still no work mmmmm no need for start

This was just a fraction of code... which outputs something abnormal

 

can you show me the piece of code

Here is some...

require_once("config.php");//зареждане на mySQL настройки
require_once("functions.php");//зареждане на базови функции
define("BASEDIR", getBasedir($_SERVER["PHP_SELF"]));//дефиниране на "нулева" директория
if (is_array($mysql)) {
$db = new mySQL($mysql["host"], $mysql["user"], $mysql["pass"], $mysql["db"]);
$db_prefix = $mysql["db_prefix"];
}
else die("mySQL конгигурацията е невалидна");
//инициализиране на връзка с база данни
$query = $db->dbquery("SELECT * FROM ".$db_prefix."settings");
if ($query) {
$settings = $db->dbarray();
if (is_array($settings)) {
	session_start();
	$_SESSION["shit"] == "MUUU";
	print_r($_SESSION);
}
else die("Невалидни настройки");
}
else die("Невалидни настройки");
//извличане на настройки и инициализиране на сесия

The script passes to the session_start() and when it comes to print_r, it spits out only "Array ( )"

Oohohohohoho Oh my god... That was a new one...  ;D heah... thanks... I'm really blind in that time of the night... oh god...  ;D reeeeally nice one... it was the "==" darn I must stop copy paste from anywhere I see a reiterate code.. when copy something from IF (..) and just change the variable.. this is what you get...  ;) Hm... I guess I need to get some sleep... It's 02:33 AM here and I'm getting really buggy... Good night all... Thanks!  ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.