PHP
  Home arrow PHP arrow Page 4 - Introduction to Maintaining the State of Applications with PHP Sessions
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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