Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use session_start()?

Tags:

php

session

I've been going through some $_SESSION examples and I'm a little confused, should i use session_start() every time before I access or set $_SESSION['variable'] or should I only use session_start() once per page or just once the user has successfully logged in?

like image 581
grasshopper Avatar asked Dec 06 '22 14:12

grasshopper


1 Answers

Use it once per page, at the very top, before you plan to use any $_SESSION variables

like image 125
John Conde Avatar answered Dec 10 '22 13:12

John Conde