Jump to content

session variables


natalieG

Recommended Posts

in the file index-2, we want to have a differenf banner[headerswish.html] the first
time the application is opened and after that we want the banner[statichead.html] to show.
we do start the application on the first line of the file with

session_start();

[MORE CODE]

[b]<tr><td>
<?php if (isset($_SESSION['START']))
{include 'statichead.html';} else
{include 'headerswish.html';} ?>
</td></tr>[/b]

[MORE CODE TO LAST LINE]

$_SESSION['START']=1;

What happens is that even on the first execution, before $_SESSION['START'] is set,
the banner headersawish is shown. So, it acts liuke the session variable is always set.

Thanks,

Jennifer
Link to comment
https://forums.phpfreaks.com/topic/6852-session-variables/
Share on other sites


First delete any session cookies and/or exit the browser before each test (I'm assuming that you're using default php.ini settings).

The first time it should include headerswish, and there after statichead (until session expires).

What you stated is what is supposed to happen: "...on the first execution, before $_SESSION['START'] is set, the banner headersawish is shown."

If after the first time it keeps showing headerswith, then it means your sessions are NOT being saved. See my session troubleshooting post in the FAQ page pinned at the top of the newbie topic area for help.
Link to comment
https://forums.phpfreaks.com/topic/6852-session-variables/#findComment-24942
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.