Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-09-03
8
Medium Priority
?
689 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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 668 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 668 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 664 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

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.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

688 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