SESSIONS creating trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anandkanatt
Forum Newbie
Posts: 3
Joined: Fri Aug 05, 2005 5:27 am
Location: Inside Apache
Contact:

SESSIONS creating trouble

Post 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.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

nothing is jumping out at me right now...can we see some code?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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".
anandkanatt
Forum Newbie
Posts: 3
Joined: Fri Aug 05, 2005 5:27 am
Location: Inside Apache
Contact:

hey i got the workaround

Post 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
Post Reply