Solved

Session reserved names?

Posted on 2008-10-02
5
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Richard Quadling
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:Richard Quadling
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

691 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