|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hi there,
on http://www.php.net/manual/en/printwn/ref.session.php i found a simple example to see how session variables work. i modified it a little bit to show the result. see below. PHP Code:
my problem is: the counter always shows "0". as i read across several forum-entries and the php-manual it is not nessecary to use session_register or something else to make this example work cause i'm using php 4.0.6. any ideas are welcome thanx, tigercat |
|
#2
|
||||
|
||||
|
Hi,
You have misread the information, quote from the manual: Quote:
So if you are using PHP 4.0.6 or less you need to replace the $_SESSION with $HTTP_SESSION_VARS but you still need to use the session_register function. The only time you dont use the session_register function is if you are using $_SESSION. HTH
__________________
--------------------- -- SilkySmooth -- --------------------- Proxy | Little Directory |
|
#3
|
||||
|
||||
|
hi there again
thanx for your reply. i still think there was some truth im my qustion - refering to http://www.php.net/manual/en/printw...on-register.php Quote:
but i think that's not the main topic. i rather think there must be something to add in the example and i don't know what it is. all the post in this forum dealing with "sessions" show it a similar way but i'm not lucky with any of them. additional: running linux, apache 1.3.19 greetings tigercat |
|
#4
|
||||
|
||||
|
Read this comment posted in the user comments section of that page and you will uinderstand more clearly what I mean
-------------------------------------------------------------------------------- ddan6709@yahoo.com 28-Aug-2002 04:44 I'm writing my first PHP application and I?ve tested the saving of the session variables (I use PHP 4.0.6 on SuSE Linux). I've noticed the following: 1. If register_globals is ON, the variables cannot be seen in another page if you don't issue a session_register() after you set the variables. For example the following code: <?php session_start (); $HTTP_SESSION_VARS[ 'testvar'] = "variable transmission test"; $testvar = 'modified'; echo "<a href= \"./secpage.php\">Link</a>"; ?> won't display anything in a second page generated by the code: <?php session_start (); echo "Second Page!"; echo " </br> "; if (isset($HTTP_SESSION_VARS[ 'testvar'])) { echo "HTTP_SESSION_VARS: " . $HTTP_SESSION_VARS[ 'testvar']; }; echo " </br> "; if (isset($testvar)) { echo "testvar: ". $testvar; }; ?> After I've added the session_register('testvar') line after setting the variables, the following is displayed in the second page: HTTP_SESSION_VARS: modified testvar: modified These is strange because the manual specify not to use session_register if we use $HTTP_SESSION_VARS. 2. If register_globals is off, you don't need to use session_register('testvar') but in the second page displays: HTTP_SESSION_VARS: variable transmission test The conclusion is that if you want your code to work with register_globals set either to On or OFF you must use session_register(). You must also use only $HTTP_SESSION_VARS to set the variable. |
|
#5
|
||||
|
||||
|
hi there SilkySmooth
you were right. with your post i could solve my problem. thanks very much. tigercat |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > simple session example |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|