1

I have unique session variables being set at different pages. I want to make my session variables discreet and localized in its respective page. The problem is that php stores a session id as a cookie for each user so that sessions are only unique to a user and not to pages.

How do I restrict sessions on a page to page setup?

1 Answers1

5

You'd be better off using a SINGLE session ID, and storing each of your page's localized data in a sub-section of the session, e.g.

$_SESSION['pages']['index.html'] = ...
$_SESSION['pages']['sitemap.html'] = ...

It is better to have just a single session floating around, rather than multiple ones. Unless your site is very small, you run the risk of exceeding the browser's per-site cookie limit, and you'll start losing sessions as the browser deletes 'old' cookies to make space for 'new' ones.

Marc B
  • 356,200
  • 43
  • 426
  • 500