I am trying to use sessions with PHP. I have page1.php with a form on it, that refers to page2.php in the action attribute. I echo’ed the session_id() on both pages and got a different result each time. I made sure to start both pages with session_start() and I included a hidden input field on page1.php with PHPSESSID as its name.
Have you made sure that your browser is saving your cookies? Browsing in private mode, or having disabled this option in your browser settings would prevent your browser from saving cookies
I thought sessions were not saved in cookies but instead were saved on the web server.
the session data itself is, but it also creates a session ID cookie which tells the server which session data is the users. Without the cookie the server has no way of knowing who owns what session data.
I thought the hidden input field named PHPSESSID is what told the server who owns what session data.
PHPSESSID is a cookie that is passed by the browser