Jump to content

ReUsing variable


paulc8481

Recommended Posts

I am new to php and would like help understanding Sessions and session variables.  When should I or should I not make my php, sessions?  I have this Idea that by creating all my documents sessions It will always be easier to reuse all my session variables in other documents.  Is this ok or is there a way to use variable in other documents without making a session?  I want to code correctly and professionally but I don,t want to become a creature of BAD HABIT.

Link to comment
https://forums.phpfreaks.com/topic/260630-reusing-variable/
Share on other sites

Whether a value should be stored in a session or not is dependent on many factors. If the data needs to persists across sessions, then you will likely want to store it in a cookie or in a database. Typical things to store in a session are data to indicate that the user is logged in, shopping cart data, some preferences, etc.

 

It's really hard to give you an answer without knowing what the variable is used for.

Link to comment
https://forums.phpfreaks.com/topic/260630-reusing-variable/#findComment-1335765
Share on other sites

Archived

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

×
×
  • Create New...

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.