Jump to content

Archived

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

natalieG

session variables

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.