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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.