|
użytkowników online: 48
|
OPINIE UŻYTKOWNIKÓW
|
Przyznam, że jestem pod sporym wrażeniem. Od wielu lat zajmuje się grafiką przeznaczoną do druku ze szczególnym uwzględnieniem opakowań. Z radością stwierdzam, iż twórca serwisu jest moim ulubionym typem potencjalnego współpracownika (choć branża troszeczkę inna) tzn. pada pytanie i błyskawicznie pada konkretna odpowiedź bez względu na stopień skomplikowania pytania. Gorąco polecam współpracę, gdyż macie pewność że nie zostaniecie potraktowani sloganami typu "oczywiście", "nie ma sprawy" tylko otrzymacie konkretną pomoc. Tak trzymać! Na pewno jeszcze nie raz skorzystam
Paweł
Studio Gama
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
session_register (PHP 4, PHP 5) session_register --
Zarejestruj jedną lub więcej zmiennych globalnych w bieżącej sesji
Opisbool session_register ( mixed nazwa [, mixed ...] )
session_register() jest funkcją o zmiennej liczbie
argumentów, z których każdy może być albo stringiem zawierającym nazwę
zmiennej lub tablicą zawierającą nazwy zmiennych lub inne tablice. Dla
każdej napotkanej nazwy zmiennej, session_register()
rejestruje w bieżącej sesji globalną zmienną o danej nazwie.
| Uwaga! |
Jeśli skrypt ma działać niezależnie od ustawienia
register_globals, niezbędne
jest użycie tablicy
$_SESSION, jako że
elementy $_SESSION są atomatycznie rejestrowane.
Jeśli skrypt korzysta z session_register(), nie
będzie on działać w środowisku z wyłączoną dyrektywą
register_globals.
|
register_globals: ważna uwaga: Od PHP w wersji 4.2.0 domyślną wartością dyrektywy
register_globals jest
off. Społeczność PHP zaleca, aby nie polegać na tej dyrektywie, ale
zamiast tego używać innych środków, takich jak superglobals.
| Uwaga! |
Funkcja ta rejestruje globalną zmienną. Jeśli
zachodzi konieczność zarejestrowania zmiennej sesyjnej z wnętrza
funkcji, należy uczynić ją globalną poprzez użycie instrukcji
global,
przez tablicę $GLOBALS[] lub prez użycie specjalnych
tablic opisanych poniżej.
|
Funkcja ta zwraca wartość TRUE jeśli wszystkie zmienne zostały
pomyślnie zarejestrowane w sesji.
Jeśli przed wywołaniem tej funkcji nie wywołano
session_start(), dokonane zostanie niejawne wywołanie
session_start() bez żadnych parametrów. Tablica
$_SESSION nie naśladuje tego zachowania i wymaga
wywołania session_start() przed korzystaniem z niej.
Możesz tworzyć zmienne sesyjne po prostu przez dopisywanie odpowiednich
wpisów do tablic $_SESSION lub
$HTTP_SESSION_VARS (PHP < 4.1.0).
Notatka:
W chwili obecnej niemożliwe jest zarejestrowanie w sesji zmiennych
zawierających zasoby. Na przykład, nie możesz stworzyć połączenia do
bazy danych i zachować identyfikator połączenia jako zmienną sesyjną i
oczekować, że połączenie ciągle będzie aktywne po odtworzeniu danych
sesji. Funkcję PHP, która zwraca zasoby, identyfikuje się przez
zwracanie typu resource w definicji funkcji. Listę
funkcji, które zwracają zasoby, można znaleźć w załączniku
typy zasobów.
Jeśli użyta jest tablica $_SESSION (lub
$HTTP_SESSION_VARS dla PHP 4.0.6 i starszych),
przypisz vartość do $_SESSION, na przykład
$_SESSION['var'] = 'ABC';
Patrz także: session_is_registered(),
session_unregister() i
$_SESSION.
User Contributed Noteswebmaster AT thedemosite.co.uk
20-Dec-2005 08:41
It states above that there is no need to set $HTTP_SESSION_VARS or to use session_register if you are using >PHP4.1x but this is NOT the case! [dependant upon your system]
Using PHP5 you can set a session variable like this:
if(!session_id()) session_start();
$_SESSION['your_id']=$your_id;
BUT, with PHP4 you need to use (also fine for PHP5):
if(!session_id()) session_start();
session_register("your_id");//used for older versions of PHP
$HTTP_SESSION_VARS['your_id']=$your_id;//used for older versions of PHP
$_SESSION['your_id']=$your_id;
//tested on PHP4 on Linux, FreeBSD and Windows.
So if you are updating your scripts ready for use with PHP5 but still running on version 4 then use the later method.
info at miguelcenaculo dot com
27-Nov-2005 07:02
I spent a night and some hours to figure why every $_SESSION variables passed ok from one page to another, some of them were incremented in some include files.. but one of them just dont appear in the destination page.. The session id was the same in both pages but for some reason this didnt work for $_SESSION['TEST'].. (PHP ver 4.3.11)
It only worked with session_register('TEST') before i use $_SESSION['TEST'].. then i used phpinfo to check for register_globals and i saw it was ON.. but even so, the $_SESSION should be global here and should register a session var automaticaly. Anyway, it started working with session_register().
David B.
09-Jun-2005 06:38
Note that with the existence of both $_SESSION and references, it is not necessary to use register_globals() if you don't want your code cluttered up with references to the $_SESSION superglobal. Just do something like:
$_SESSION['some_variable'] =& $GLOBALS['some_variable'];
And henceforth you can just use $some_variable and forget all about typing $_SESSION all the time. Though on subsequent sessions if you want to get at that value with a global variable in a similar fashion, you'll of course have to use:
$GLOBALS['some_variable'] =& $_SESSION['some_variable'];
It's fairly easy to take that knowledge and come up with a user-defined function that does 90+% of what the old session_register() did...
T
12-Apr-2005 03:24
make sure you include files as "filename.php" and not "http://www.yourdomain.com/filename.php" or sessions won't work - spent a day trying to figure out this problem.
Also make sure that $_SESSION['$name'] does not any $name variables that you send with POST OF GET - spent another day until i noticed this could be the cause of my problems.
mantas at systemnetwork dot net
19-Mar-2005 12:40
I have 3 files:
- The first is the form that contains various fields.
- Second is the php script that the form submits data to. This file then stores acquired values to the session.
- Finally the third file is the php script that accesses data from the session
So the first script:
<?
session_start();
$title = $_POST["title"];
$fname = $_POST["fname"];
$_SESSION["first"] = $fname;
?>
... All we do here is set values from HTTP POST request.
Now the second script:
<?
session_start();
echo $_SESSION["first"];
?>
... Here we try to print out the session variable that was set in the previous script.
This demonstrates the use of $_SESSION. There is no need to declare $_SESSION to be global since it is already global, thus can be accessed from anywhere.
Tested on PHP 4.
erik
|