Jump to content

  •  

Photo
- - - - -

P10: Passing Variables Intro

PHP4Beginners

  • Please log in to reply
No replies to this topic

#1 DraxxTV

DraxxTV

    Member

  • SuperGeek
  • PipPip
  • 14 posts

Posted 06 July 2014 - 09:27 PM

In php there are plenty of different times where you will need to work with multiple scripts or different part of scripts. When you are doing this, you will often need to pass variables like settings or users information. Because of this, you need to choose the best and most secure method. You will see links below to guides explaining each method as well as information about that method.
POST
The POST method allows a user to collect information from a form when sent with method="post". When information is sent this way, it is done invisibly using HTTP headers. There is no restrictions when it comes to the amount of data that can be sent however, there is an 8 MB max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file). Information sent can be accessed by viewing the contents inside the $_POST array.
Click here tutorial on how to use this
Click more information on the W3School Web Page
GET
The GET method allows the user to pass variables through a url. Information sent this way is visible to the user and should not be used to send private information such as usernames and passwords. There is also a limit on the amount of data which can be sent this way and should only be used if data is smaller than 2000 characters.
Click here tutorial on how to use this
Click more information on the W3School Web Page

Sessions

A PHP Session allows information to be stored on a server for later use. Information saved this way is only temporary and will only be kept until the user leaves the website. They work by creating a Unique ID (UID) for each visitor and storing information for this UID on the server. There are no limit on the number of variables; also, there's no limit on the amount of data you can store in a session. The only limits are the power of your server. If for example you had sessions of 50+MB and a thousand visitors, You may find things been very slow and you may not be able to deal with the load.
Click here tutorial on how to use this

Click more information on the W3School Web Page

COOKIES

A Cookie is a small file that is stored on a person's machine and is often used to help identify a user. When a person visits a page, the cookie is sent alone by the browser and then read by the server. Common uses for this are to tell if someone is logged in or to store information about their account preferences. When a cookie is sent and received, it is automatically URLEncoded (this can be prevented). The limits on the size of a cookie and the amount of data which can be stored is dependent on the browser the user is using.
Click here tutorial on how to use this

Click more information on the W3School Web Page







Also tagged with one or more of these keywords: PHP4Beginners