Recently in PHP

php.pngSessions are a way to store data on the server rather than in a cookie on the clients computer.

One problem with sessions, is that they work for one visit only, whereas cookies can track information from one session to another by using the time() paramater. It's up to you, to decide what works best for your website. Just like with cookies you have add this session creation before any other code on your page.

To create a session in php you write the following:

    <?php
        session_start( );
    ?>
    <html>
        <head>
            <title>Page Title</title>
        <head>
        <body>

Once the session has been started, data can be added to the session by using the $_SESSION variable. To create, a username variable with a value of "hockeyFanatic":

Note: $_SESSION is what is considered to be a php superglobal variable and is available at all times.
BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota
php.pngWorking with cookies in php is rather simple, as is working with php in general.

Cookie Basics:
Cookies are text files used to store data on a client's computer, allowing the ability to store visitor data during their visit, or across multiple visits. They are most commonly used for personalizing a site for the visitor, by  storing user information so they don't need to log in every time they visit and have many other uses since you store almost any data in a cookie.

Creating, reading and deleting cookies is very simple to do with PHP.

Creating a cookie:
Before you start, there is one important rule: The cookie code must be the first line of your php document unlike with javascript. It must be before the head of your page, and before any other code on the page. If not, you will get a "Headers already sent" error. So to set a cookie, your page should look like this:
BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota
php.pngIf you need to pass one single $var from page to page, this would be the most simple of ways to do it using php. Which also results in very little code for handling it.

First create the url with the var attached. As so.

    http://www.yoursite.com?querystring

Notice there's no assignment using an equal sign as you'd normally do.(Like this)

    http://www.yoursite.com?str=querystring

Now we have to read the query string upon page change.
BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, BMW, BMW, BMW, BMW, Acura, Honda, Acura Forerunner, SUV, BMW, Mercedes, Toyota


Chicago Blackhawks
Chicago Blackhawks
Stanley Cup
Stanley Cup
Pittsburgh Penguins
Pittsburgh Penguins
Boston Bruins
Boston Bruins
Fire & Flames
Fire & Flames








 


Categories

BMW, Toyota, BMW, Saab, Audi, Nissan Mercedes, BMW, Nissan, Honda, Acura, Honda, Acura Forerunner,bmw bmw bmw SUV, BMW, Mercedes, Toyota