Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links



How to Register a Variable with $ _SESSION?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 28-02-2010
The Recruiter's Avatar
Member
 
Join Date: Aug 2006
Posts: 80
How to Register a Variable with $ _SESSION?

Hi friends,
I would like to thank you first for the help that you did last time. Now I need your help more.!! I want to know about the $_Session. Actually I want to register a variable using that. I don't have much knowledge about that. So i have not tried to do anything. Please tell me how to Register a variable with $ _SESSION? Help me as soon as you can.!!
__________________
Don't be afraid of darkness, it's in your heart anyway.
Reply With Quote
  #2  
Old 28-02-2010
Warner's Avatar
Member
 
Join Date: Mar 2008
Posts: 349
Re: How to Register a Variable with $ _SESSION?

If register_globals is disabled, only elements of the global array $ _SESSION contain variables recorded in the session. The restored session variables will only be available in $ _SESSION. You should keep in mind that $ _SESSION is available as a global variable just like $ _POST, $ _GET, $ _REQUEST, etc. Therefore, you do not need to use the reserved word global with $ _SESSION. The array keys $ _SESSION are subject to the same limitations as regular variable names in PHP. For example, you cannot start with a number, but start with a letter or underscore '_'.
Reply With Quote
  #3  
Old 28-02-2010
Viensterrr's Avatar
Member
 
Join Date: Jul 2006
Posts: 232
Re: How to Register a Variable with $ _SESSION?

If register_globals is disabled, only elements of the global array $ _SESSION contain variables recorded in the session. The restored session variables will only be available in $ _SESSION. Use of $ _SESSION is recommended for improved security and code readability. With $ _SESSION, there is no need to use functions session_register (), session_unregister () and session_is_registered ().Session variables are accessible like any other variable.
__________________
Signatures reduce available bandwidth
Reply With Quote
  #4  
Old 28-02-2010
MELTRONICS's Avatar
Member
 
Join Date: Aug 2006
Posts: 226
Re: How to Register a Variable with $ _SESSION?

I am providing you with the coding that will help you to register a variable with $ _SESSION. So , just have a look at the sample of coding :
PHP Code:
<?php 
session_start 
(); 
if (!isset( 
$_SESSION 'count' ])) { 
$_SESSION 'count' ] = 
} else { 
$_SESSION 'count' ]++; 

?>
__________________
3.2 (northwood)
2gig ram
ATI AIW X800xt 256mb
Gigabyte GA-8knxp 875p Chipset
Optiwrite 8X DVD Burner
Win XP PRO Sp2 (Works Perfectly)
2 SATA Raptor 74gig Raid 0
2 7200 IDE 320gig HD
Reply With Quote
  #5  
Old 28-02-2010
Deabelos's Avatar
Member
 
Join Date: Jul 2006
Posts: 233
Re: How to Register a Variable with $ _SESSION?

If register_globals is enabled, then each global variable can be registered as session variables, and all session variables will be reconstructed as global variables. Since PHP must know which global variables are registered as session variables, users need to register variables with session_register () while $ HTTP_SESSION_VARS and $ _SESSION does not require session_register (). You can remove a variable with $ _SESSION and register_globals disabled by using the following code :
PHP Code:
<?php 
session_start 
(); 
unset( 
$_SESSION 'count' ]); 
?>
__________________
IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Register a Variable with $ _SESSION?"
Thread Thread Starter Forum Replies Last Post
Retrieve Variable In JSP Amaresh Software Development 4 10-02-2010 09:14 PM
What is the difference between session_register and $_session? garfield1 Software Development 3 05-09-2009 09:52 AM
Runtime Error 91 : Object Variable or with block variable not set Ryan21 Software Development 2 28-08-2009 08:51 PM
What is Global Variable static? Declaring static variable instead of Global variable Reckon Software Development 3 25-04-2009 12:34 PM
Variable height in CSS Sentential Software Development 8 22-10-2008 03:51 PM


All times are GMT +5.5. The time now is 07:40 AM.