|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
using session vars with PHP
Hi
I am doing some php stuff which will need session vars to be set to remain active during the whole session across all pages in the application. Question: Do I have to put session_start(); on every page that will need to set, read or create session vars? Also is it best to use session_register(); or $_SESSION[]? I have started by using $_SESSION, as I am told this is better? What then is the method for reading or changing these vars once created? Sorry, a lot of questions! Thanks, any help appreciated! |
|
#2
|
|||
|
|||
|
fox66,
You must always perform a call to session_start() at the beginning of every page where you need to access the session variables. Otherwise, you won't be able to use them! As for the session_register vs $_SESSION, use the $_SESSION autoglobal. It gives you greater functionality than session_register. When you want to work with the variables, simply modify, add, read or delete them within the $_SESSION array. Manipulate the array just like you would any other. -Jeb. |
|
#3
|
||||
|
||||
|
Personally fox, I agree with Jeb.. adding or removing items from the $_SESSION array is much easier than registering or unregistering session variables... I'm lazy.. so it works for me
![]() |
|
#4
|
|||
|
|||
|
many thanks, $_SESSION it is!
Cheers |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > using session vars with PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|