Logan
Logan

Reputation: 55

Is unsetting $_SESSION variable a bad idea before setting session var?

In a page I'm designing, I'm storing data via $_session but since I'm calling the pages dynamically with jquery I wanted to add some security and unset($_SESSION['var']) before i set them just in case anything would happen. My question is if unsetting session a bad idea before it is set, or is it completely valid?

Upvotes: 3

Views: 81

Answers (1)

Pekka
Pekka

Reputation: 449613

It's unnecessary and will have no effect.

If you are calling sensitive data through Ajax calls, you need to properly secure it against attacks, just as you would secure a normal page - for example by having a session-based login, and checking whether the current user is logged in!

Upvotes: 4

Related Questions