PHP
  Home arrow PHP arrow Page 4 - Introduction to Maintaining the State ...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Introduction to Maintaining the State of Applications with PHP Sessions
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2006-04-26

    Table of Contents:
  • Introduction to Maintaining the State of Applications with PHP Sessions
  • Working with persistent data: the basics of session management
  • Ending a session: using the “session_destroy()” function
  • More session functions ahead: finding out the name of active sessions
  • Configuring the PHP session module: using some helpful session functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introduction to Maintaining the State of Applications with PHP Sessions - More session functions ahead: finding out the name of active sessions


    (Page 4 of 5 )

    Just in case you didn’t know, the PHP session module offers many other helpful functions that can be used for obtaining the values of specific parameters, which are included within the set of directives of the php.ini configuration file. However, let me first show you another illustrative example, which displays the name of an active session:

    session_start();
    echo session_name(); // displays PHPSESSID
    // generate new session name
    session_name('NEW_SESSION_NAME'); //displays NEW_SESSION_NAME
    echo session_name();

    As shown in the above script, the name of a session can be obtained by using the “session_name()” function. Very similar to the “session_id()” function that I described a few lines above, this function returns the name of the active session or assigns a new name to it.

    After running the previous snippet, the output I get on my browser is the following:

    PHPSESSID
    NEW_SESSION_NAME

    If a new session is started with the same browser or even with a different one, the value returned by the “session_name()” function (without passing any argument to it) will always be “PHPSESSID,” because this is the default session name assigned in the php.ini configuration file.

    Right, as you saw, the PHP session module exposes many interesting functions, either for retrieving or manipulating some parameters assigned as default values within the php.ini file. Keeping in mind this concept, join me in the next section to learn how these values can be used (or eventually changed) within your PHP scripts.

    More PHP Articles
    More By Alejandro Gervasio


       · If you're insterested on learning the basics of PHP sessions along with advanced...
       · this is the nice article to start with sessions i like it very much and waiting for...
       · Thank you for posting your comments regarding this article on PHP sessions. Also,...
       · Well put simple and clear. This article is basic and mostly talks about stuff I knew...
       · Hello Sig,Thank you for commenting on my PHP article. Of course, I'm glad to...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT