Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
How to Use Sessions and Session Variables in PHP
Oct 04, 2018 @ 16:43:35

If you're new to PHP and are still learning the ropes, one thing that could be confusing is how the language handles sessions and the data they contain. In this new tutorial from the TutsPlus.com site, they introduce you to the basics of using sessions and the variables they contain to get you up to speed.

Session handling is a key concept in PHP that enables user information to be persisted across all the pages of a website or app. In this post, you'll learn the basics of session handling in PHP.

We'll start with an explanation of how sessions work and how they are related to cookies. Then we'll look at a few code snippets that demonstrate how to work with sessions. You'll learn how to create and destroy sessions, and how to change session variables.

The post starts with a general overview of what a session is and how the information flows back and forth from the user to the server. To illustrate, they provide an example of a simple login process, complete with flow diagram. The tutorial then shows how to:

  • start a new session
  • get the session ID
  • automatically start a session
  • destroying a session

It then covers the use of session variables: setting them, removing them and altering their contents.

tagged: session handling tutorial introduction start destroy variable

Link: https://code.tutsplus.com/tutorials/how-to-use-sessions-and-session-variables-in-php--cms-31839

Stoimen Popov:
PHP: Don’t Call the Destructor Explicitly
Jun 27, 2016 @ 17:52:39

In a new post to his site Stoimen Popov makes the recommendation to not call the destructor explicitly in your code and provides some alternatives.

PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++” says the documentation for destructors. [...] Well, as you can not call the constructor explicitly [...] so we should not call the destructor explicitly. The problem is that I’ve seen this many times, but it’s a pity that this won’t destroy the object and it is still a valid PHP code.

He talks about __destruct and it's role in PHP's set of "magic methods" and what they exist to do. He then gets into a few examples of what code could look like that uses a destructor and the difference between normal handling calling the destructor explicitly. The main differences is that calling it explicitly does not destroy the object, it's basically like calling any other method. He does include an interesting method for destroying the object - setting it to null - and notes that the destructor fires then too. He also points out a few interesting things about cloning objects and how object references work when setting nulls as in the previous example.

tagged: destructor explicit call object destroy null tutorial

Link: http://www.stoimen.com/blog/2011/11/14/php-dont-call-the-destructor-explicitly/

PHPMaster.com:
PHP Sessions
Nov 17, 2011 @ 16:19:08

On PHPMaster.com today there's a new introductory tutorial for those trying to figure out sessions in PHP. Sessions can be one of the most powerful tools at your disposal and handling them correctly can sometimes be a little tricky.

$_SESSION is a special array used to store information across the page requests a user makes during his visit to your website or web application. The most fundamental way to explain what a sessions is like is to imagine the following scenario: You are working with an application. You open it, make some changes, and then you close it. That is a session in it’s simplest form.

They start with a basic "how to use them" example of setting a username value to the current session and pulling the value back out. They also show the use of the session_unset and session_destroy methods for ending the session. Some security tips are mentioned too - timeouts, regenerating the session ID, destroying them correctly and using a more permanent storage option (by default, they store on the local disk).

tagged: session tutorial introduction security destroy timeout

Link:

PHP F1:
PHP Session Tutorial
Jul 10, 2007 @ 13:46:57

If you're just getting started with PHP, some things can be a bit confusing. For a lot of developers, sessions seem to hold a bit of mystery and can be difficult to use. To help combat this, PHP F1 has posted this new tutorial to demystify this super-handy PHP functionality.

In this tutorial I will show you how to work with sessions in PHP. You will learn how to transfer information between pages. [...] Using sessions you can transfer data between various pages. If you are using sessions then each of your visitors will got a unique id. This id will identify various visitors and with the help of this id are the user data stored on the server.

They introduce what sessions are (the concept behind them), some of the php.ini settings that can be used to change how they work and code to work with assigning values to a session, checking for values in them and removing/destroying the session and its information.

tagged: session introduction tutorial create destroy assign session introduction tutorial create destroy assign

Link:

PHP F1:
PHP Session Tutorial
Jul 10, 2007 @ 13:46:57

If you're just getting started with PHP, some things can be a bit confusing. For a lot of developers, sessions seem to hold a bit of mystery and can be difficult to use. To help combat this, PHP F1 has posted this new tutorial to demystify this super-handy PHP functionality.

In this tutorial I will show you how to work with sessions in PHP. You will learn how to transfer information between pages. [...] Using sessions you can transfer data between various pages. If you are using sessions then each of your visitors will got a unique id. This id will identify various visitors and with the help of this id are the user data stored on the server.

They introduce what sessions are (the concept behind them), some of the php.ini settings that can be used to change how they work and code to work with assigning values to a session, checking for values in them and removing/destroying the session and its information.

tagged: session introduction tutorial create destroy assign session introduction tutorial create destroy assign

Link:

Christian Stocker's Blog:
"Wordpress hat den Blog-Hosting Markt versaut"
May 09, 2006 @ 11:15:54

There's an interesting new post on Christian Stocker's blog looking at what some consider to be "ruining the blog hosting market" - WordPress (as mentioned by the Swiss Blog Awards Panel).

What I basically wanted to say is, that the installation of Wordpress is sooo easy and there are so many features built in, resp. plugins available, that there are not many incentives to use a dedicated blog host provider and maybe even pay for it. Why should I pay 5 Euro a month to a blog hoster, when I can get for the same price a full hosting, with more disc space, full control over the design, my own domain and certainly more features (I can not only run my blog there, but also other software and get dozens of email addresses).

He argues that since WordPress is such an easy install (and an easy thing to move), but you're also foregoing the benefit of having someone there to help/ask questions. He also notes, though, that a possible 90 percent of the population doesn't want to mess with installing WordPress (good for blog hosters), but of those, most probably wish they could have a more flexible solution (bad for blog hosters).

I don't say, that this counts for everyone, there is certainly a market for bloghosters (be it for free or paid), but Wordpress et al. made that potential market much much smaller. Like eg. Apache made the commercial Webserver market really small :)
tagged: wordpress blog host destroy market easy wordpress blog host destroy market easy

Link:

Christian Stocker's Blog:
"Wordpress hat den Blog-Hosting Markt versaut"
May 09, 2006 @ 11:15:54

There's an interesting new post on Christian Stocker's blog looking at what some consider to be "ruining the blog hosting market" - WordPress (as mentioned by the Swiss Blog Awards Panel).

What I basically wanted to say is, that the installation of Wordpress is sooo easy and there are so many features built in, resp. plugins available, that there are not many incentives to use a dedicated blog host provider and maybe even pay for it. Why should I pay 5 Euro a month to a blog hoster, when I can get for the same price a full hosting, with more disc space, full control over the design, my own domain and certainly more features (I can not only run my blog there, but also other software and get dozens of email addresses).

He argues that since WordPress is such an easy install (and an easy thing to move), but you're also foregoing the benefit of having someone there to help/ask questions. He also notes, though, that a possible 90 percent of the population doesn't want to mess with installing WordPress (good for blog hosters), but of those, most probably wish they could have a more flexible solution (bad for blog hosters).

I don't say, that this counts for everyone, there is certainly a market for bloghosters (be it for free or paid), but Wordpress et al. made that potential market much much smaller. Like eg. Apache made the commercial Webserver market really small :)
tagged: wordpress blog host destroy market easy wordpress blog host destroy market easy

Link:


Trending Topics: