That still doesn’t answer the question asked. If $book_mobi is empty, or contains a false value, all the code being used to store it in a session variable, then echo it later could be working, but echoing it won’t show anything. Instead of echoing the session variable, for debugging purposes, use var_dump($_SESSION[‘mySessionVariable’]);
The Notice: Undefined variable: phone… message isn’t coming from any session variable code. That’s for a regular variable, i.e. $phone. Also, you are using an older version of php. In php8, that would be a Warning message.
You are showing code with the session_start() located after content on the page. This will normally not work and produce a Warning message. This can ‘work’ if php’s output_buffering is turned on. However, an issue with output_buffering being on is it hides non-fatal php errors and other output from your code if you are doing redirects. So, three things -
- Is php’s error_reporting set to E_ALL, so that ALL php errors will get reported?
- Is php’s output_buffering turned on?
- How are you getting from the first page, where the session variable is being set, to the second page, where you are trying to use it? A redirect? A link?
For finding out the first 2 items, you can use a phpinfo() statement in a .php script file, then search for those settings in the output.
I’m also wondering why are you are needing to do this for this value? Generally, you would only store things in session variables that you need to persist between page requests, such as the id of a logged in user, a language choice, …
Lastly, I recommend that you start with two new files, only put the session setting/use code in them, and get this to work first.