title: PHP Custom Session Name
body: <p>I've been coding a website for a long time, but never used the <code>session_name()</code> function built in PHP to set a custom session name instead of the default (PHPSESSID).</p>
  <p>I've had a login page that redirects you to another file after a successful login. In that file, I was basically checking <code>isset($_SESSION)</code> if I wasn't set I redirect to the login page. Otherwise, I say <code>Hello $_SESSION[&quot;Username&quot;]</code>.</p>
  <p>I've recently decided to use the <code>session_name</code> and set a custom name. However, now the script in the second file (checking if <code>$_SESSION</code> was set) always says it's not set. I just changed the session name.</p>
  <p>Then I searched around on Google and have seen that I need to do again <code>sesssion_name()</code> and <code>session_start()</code> in the second file to get access to the username.</p>
  <p><strong>TL;DR</strong></p>
  <p>Do I always need to do <code>session_name()</code> and <code>session_start()</code> on every file I want to get access to the data of my session with a custom session name?</p>
  <p><em>I can clarify some things if it's unclear; might not be easy to understand.</em></p>