Solved

Session reserved names?

Posted on 2008-10-02
5
220 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 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

11 Experts available now in Live!

Get 1:1 Help Now