Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Alan Mattanó
PLUS
Alan Mattanó
Courses Plus Student 12,188 Points

Do SESSION work in Treehouse Workspaces?

My code:

index.php

  <?php session_start(); 

  $_SESSION['data'] = "hello world!";

  var_dump( $_SESSION );

  // Works if session cookie was accepted
  echo '<br /><a href="page2.php">page 2</a>';
  exit;
  ?>

In page2.php

  <?php session_start(); 

  var_dump( $_SESSION );
  exit;
  ?>

2 Answers

Hey Alan,

Unfortunately, they don't in Workspaces. But you can use a local environment to test your session code. I use XAMPP for my local server, and I love it.

You're welcome, Alan! I actually had to test this to make sure myself, because I hadn't yet tried to use session variables in Workspaces yet lol Your code works great on my local server but not in workspaces :\ Oh well, now you can test your session code! =]