Solved

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

Posted on 2010-09-03
8
682 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 110

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 dynamically set the form action using jQuery.

624 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