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
Share on other sites

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

Link to comment
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 :(

Link to comment
Share on other sites

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 ( )"

Link to comment
Share on other sites

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!  ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.