Solved

Session reserved names?

Posted on 2008-10-02
5
221 Views
Last Modified: 2012-05-05
I am using a session variable called "type", for example:

$_SESSION['type'] = "demo".

In a subsequent php program, I look at $_SESSION['type'] and it is "D". I don't think I changed it inbetween.

Is $_SESSION['type'] a reserved word?

Thanks
0
Comment
Question by:Richard Korts
  • 2
  • 2
5 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22627148
>> I don't think I changed it inbetween.
I think you did

>>Is $_SESSION['type'] a reserved word?
Not that I know of.
0
 

Author Closing Comment

by:Richard Korts
ID: 31502501
I found it after I posted the question. Thanks!
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 22627254
Completely agree with Hielo on this one.

There are no reserved words like this. $_SESSION has a special meaning (which you understand).

Do you have any code at all which interacts with $_SESSION? Not just $_SESSION['type'].

if ('D' = $_SESSION['type'])

rather than ...

if ('D' == $_SESSION['type'])

maybe?

Temporarily enable ALL errors, warnings and notices ...

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

at the top of the scripts, or in a global include file if you have one.

See if you have anything in relation to the session.

Watch out for the error of headers sent before session cookie. That will be expected if the error occurs BEFORE session_start(); Just ignore those for the sake of this debugging exercise.


Come back with what you've got.



0
 
LVL 82

Expert Comment

by:hielo
ID: 22628624
>>if ('D' = $_SESSION['type']) rather than ...
That would still not change the session :)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 22629011
Doh. Moron here.

if ($_SESSION['type'] = 'D')

rather than ...

if ($_SESSION['type'] == 'D')


That is the EXACT reason why I put my constants first.

You cannot assign anything to the string 'D'. You'll get an parse error or a fatal error depending how the code is written. But having it this way around, you CAN assign, thinking you are testing and the test passes (as the assignment is evaluated as True).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now