Page 1 of 1

SESSIONS creating trouble

Posted: Tue Aug 30, 2005 12:01 pm
by anandkanatt
I am working on a small login form here both admin and password is checked against a row in table and a session variable is set to store result ie if login of user is okay I set $_SESSION['user'] = TRUE; but my problem is when i try to access this session variable in another page it shows an error "Notice: Undefined index: user" , i am passing session ID to this page and session_start() is also specified at top of the page. I am using IIS 5.0 and PHP 5. MY browser accepts cookies from other sites .. please help me with this problem can anyone suggest the best way to use sessions in PHP coz i am new to PHP.

Posted: Tue Aug 30, 2005 1:36 pm
by Burrito
nothing is jumping out at me right now...can we see some code?

Posted: Tue Aug 30, 2005 2:47 pm
by raghavan20
I have been having this doubt for a long time.
Can 'TRUE' or 'FALSE' can be assigned to $variables?
I know NULL can be assigned but I dont know about the other two.

And about the problem, I guess the session variable is not I suppose.
give some other value for the session variable.
Its better if you can give us the first few lines say 10 lines of code of each file.

Posted: Tue Aug 30, 2005 2:51 pm
by Burrito
yes true false can be assigned to variables, that is how you create boolean variables (one way at least).

ex:

Code: Select all

<?
session_start();
$_SESSION['whatver'] = TRUE;

if($_SESSION['whatver'])
	echo $_SESSION['whatver'];
?>
the above should echo "1".

hey i got the workaround

Posted: Tue Aug 30, 2005 2:58 pm
by anandkanatt
hey i got the workaround ... since i am using IIS the PHPSESSID i send was not parsed before the session_start() would process so each time session_start() is called a new session was being created.

and what i did to solve was to just add

Code: Select all

session_id(@$_GET['PHPSESSID'])
line before the session_start()

I think this workaround will be useful for all the people developing PHP APPS using IIS-PHP combo.

and about the TRUE , FALSE variables .. it is perfectly ok to use these variables but the actual value stored as TRUE and FALSE is 1 and 0.

Anyway thanks for the posts ...

AK :D