Solved

Session reserved names?

Posted on 2008-10-02
5
223 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: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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Wordpress French and English Site 6 79
how to use Initialization Vector for openssl_encrypt() 5 64
what do I need to host my own web sites? 13 53
IP 10.0.1.2 / 255.0.0.0 61 57
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 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