0

I have an array of ids called $ids. I use infinite scrolling to display sets of those ids ($subset_ids) which I then put into a session variable. When I loop back through the request, I remove $subset_ids from $ids so as not to display any id twice.

When I refresh the page, how do I destroy or unset the session variable so I start with the full array of $ids again?

ian
  • 303
  • 3
  • 15

1 Answers1

0
unset($_SESSION['mykey']);

This will remove / delete the variable so you can redefine it with out interference from it's previous content.

Ahmad's suggestion $_SESSION['mykey'] = ''; would also work, but from what I have read it seems to be less efficient.

Community
  • 1
  • 1
Thomas Smyth
  • 512
  • 3
  • 9
  • 36