Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Why can I not get this Session Variable to show up?

In my header, after session_start();, I have:

$_SESSION['facebook_session_id']=$uid;

I've been able to establish the fact that it is in place. Problem is, when I open up another browser window with the following code, it doesn't show up.

session_start();
if(isset($_SESSION['facebook_session_id']))
{
echo "Yes";
}
echo $_SESSION['facebook_session_id'];

Nothing...

What am I doing wrong?
0
brucegust
Asked:
brucegust
  • 4
  • 2
  • 2
  • +1
3 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
Not enough detail.  Is it another window in the same browser?  Where are you getting $uid?  Try using a known constant like a string that says 'uid'.
0
 
brucegustPHP DeveloperAuthor Commented:
Different browser. In other words, it's a new window that opens up.
0
 
Julian HansenCommented:
Try

print_r($_SESSION)

And

if (empty($_SESSION['facebook_session_id']);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
brucegustPHP DeveloperAuthor Commented:
When I do print_r($_SESSION) I get:

Array ( [auth] => yes [fb_345882868804207_state] => b26cd96a89dc61972170d411c34f651f )
0
 
COBOLdinosaurCommented:
Different browser... then it will be a different session.  

Cd&
0
 
brucegustPHP DeveloperAuthor Commented:
Also, I put a generic session variable in place, just to rule out the possibility that the $uid variable wasn't showing up. I put $_SESSION['test']=1 in the header and then echo $_SESSION['test'] in window that opens up in a separate browser and I didn't get anything.

Bizarre!
0
 
Julian HansenCommented:
brucegust said:
when I open up another browser window
Then
Different browser. In other words, it's a new window that opens up.

This is ambiguous. If a different window in the same browser then same session if different browser (i.e. Firefox -> Chrome) = different session

So are we talking different browser or different window in same browser?
0
 
Dave BaldwinFixer of ProblemsCommented:
Yes, different browser means a different session and you should Not be able to see $_SESSION variables from the first session.  If you bring up the same page in both IE and Firefox, they will have different session id's and be different sessions.  If you bring up the two pages in separate tabs or windows in the same browser, both will be the same session.
0
 
brucegustPHP DeveloperAuthor Commented:
OK, I got it figured out.

First off, same browser. Different windows, but same browser so that wasn't the problem.

While I'm not exactly sure what was going on, I accidentally closed the window that I had been working on and when I logged back in, I was able to see the Session variable that had been, up to that point, illusive.

So, perhaps by clearing my cache, I was able to see what I hadn't been able to see beforehand. I've used the same code / approach many times in the past which is why I was freakin' trying to figure out what the problem was. But however it was remedied by logging out and logging back in, that did the trick.

Thanks for your input!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now