SoundreameR Posted July 5, 2007 Share Posted July 5, 2007 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 ( ) !!! ??? :-\ Any ideas? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 Have you added session_start(); at the start of the code? Quote Link to comment Share on other sites More sharing options...
SoundreameR Posted July 5, 2007 Author Share Posted July 5, 2007 I tried puting session_start() on different places (no effect). I tried to put it at the first line of the first file, I tried on the first line of the first included (require_once) file. Absolutely no effect... Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 can you show me the piece of code Quote Link to comment Share on other sites More sharing options...
SoundreameR Posted July 5, 2007 Author Share Posted July 5, 2007 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 ( )" Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 This might be nothing but try replacing the double quotes when you're using sessions with single quotes. I've never tried double quotes myself so have no idea whether it changes anything! Quote Link to comment Share on other sites More sharing options...
SoundreameR Posted July 5, 2007 Author Share Posted July 5, 2007 It doesn't... Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 got cha session_start();//session start with or without and declare on top of page $_SESSION["shit"] == "MUUU";// == equals use single print_r($_SESSION); Quote Link to comment Share on other sites More sharing options...
SoundreameR Posted July 5, 2007 Author Share Posted July 5, 2007 Oohohohohoho Oh my god... That was a new one... heah... thanks... I'm really blind in that time of the night... oh god... 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.