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
Solved

What does "$_SESSION['index.php']" mean?

Posted on 2010-09-03
8
664 Views
Last Modified: 2012-08-14
Hello,

I have a bit of code I am trying to modify, and it references page names as sessions all over the place.  Take for example:
if ($_SESSION['index.php'] != '') {
.. }

I try to print the session to the screen so I can see it, but using echo, print, print_r doesn't display anything.  In general use what do these sessions store? How can I print its contents?

Thanks, Liz
0
Comment
Question by:maeve100
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33600271
That's a 'session variable'.  http://www.php.net/manual/en/reserved.variables.session.php  They can be used like 'regular' variables except that they are preserved on the server so they can be set and retrieved from different pages.  If it doesn't display anything it doesn't contain anything... in Your session.  Session variables are available only to the session that created them.  Without looking at the files on the server, you can't see someone else's session variables.
0
 

Author Comment

by:maeve100
ID: 33600299
Sorry, should have been more clear - I understand that its a session variable - but what is the significance of the index.php?  I see a bunch that reference page names in the files.  Is there something special to that? Or is it just a variable name that happens to match a page name that is being used?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 167 total points
ID: 33600340
I wouldn't know, everybody gets to make up their own stuff.  It is "a variable name that happens to match a page name that is being used" but I don't know of any further significance.  If they're using it to track users on the site, you might see it used to put data in a database.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
LVL 17

Expert Comment

by:nanharbison
ID: 33600454
Can you echo it out so you can see what value it is holding? Is this in a CMS, so it is holding which template to use or something?
0
 
LVL 18

Assisted Solution

by:Matthew Kelly
Matthew Kelly earned 167 total points
ID: 33600661
It just a variable name that happens to match a page name that is being used. There is nothing special. To php, the 'index.php' is just characters, and if you changed every place SESSION["index.php"] was used to SESSION["user"], the code would function the same.

If printing it does nothing, it just means it wasn't initialized, which may or may not be an issue depending on what the code is supposed to do with it.
0
 
LVL 11

Expert Comment

by:Bruce Smith
ID: 33601962
You need to echo it at several points throughout the web-application to see exactly what it is being used for. Kind of looks like the session variable is for tracking site usage or something.
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 33602902
Here is what I would do...

1. Make sure you understand how PHP sessions work.  There are only a few functions - read the man pages for all of them, starting here.
http://us.php.net/manual/en/function.session-start.php

2. Get a code scanner (most text editors have them - something like "find in files") and search the code library for case-sensitve instances of $_SESSION.  Keep this list of search results handy.

3. Make sure that every page you want to inspect has session_start() right at the top.  Add error_reporting(E_ALL); to these scripts.

4. Modify the footer of your test page to contain this PHP code at the very end of the page.

You will be able to see the contents of the session array with that.  Hopefully between knowing where the $_SESSION array is used in the code, and what it contains at the end of the page, you'll be able to sort out the author's original intent.

<?php
// DUMP THE SESSION VARIABLES
echo "<pre>" . PHP_EOL;
var_dump($_SESSION);

Open in new window

0
 

Author Closing Comment

by:maeve100
ID: 33620147
Thats what I get for having multiple coders passing on a jumble of a project to a low level front end coder, hehe.  Thanks for helping me understand!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Creating Functions in phpMyAdmin 8 26
What's wrong with this PDO query? 5 27
PHP breaks when used in Wordpress template file 3 30
selector:validator cookies 4 30
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.  …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
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.

808 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