Solved

Session reserved names?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 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