PHP toimii muuten ihan normaalisti, mutta sessiot jostain syystä eivät. Kokeiltu on jo vaikka mitä.
PHP asennettu sekä cgi-binaryna että moduulina. Tällä hetkellä moduuliasennus.
apache httpd.conf lopussa seuraavat rivit:
# And for PHP 4.x, use:
LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
php4ts.dll kopioitu C:\PHP kansiosta C:\Program Files\Apache Group\Apache2\bin kansioon
php.ini-dist tiedosto kopioitu ja uudelleen nimetty php.ini nimiseksi C:\WINDOWS kansioon.
kyseinen tiedosto näyttää tältä session asetuksien osalta:
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
; As of PHP 4.0.1, you can define the path as:
;session.save_path = C:/omat
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
session.save_path = c:/windows/temp
; Whether to use cookies.
session.use_cookies = 1
; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1
; Name of the session (used as cookie name).
session.name = PHPSESSID
; Initialize session on request startup.
session.auto_start = 0
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
; The path for which the cookie is valid.
session.cookie_path = /
; The domain for which the cookie is valid.
session.cookie_domain =
; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.
session.gc_probability = 1
session.gc_divisor = 100
Käytössä PHP versio 4.3.7, apache 2.0.50 palvelin ja Käyttöjärjestelmänä WINDOWS XP PRO.
Sessiot vaan eivät toimi!
Miten saada sessiot toimimaan?????
PHP asennettu sekä cgi-binaryna että moduulina. Tällä hetkellä moduuliasennus.
apache httpd.conf lopussa seuraavat rivit:
# And for PHP 4.x, use:
LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
php4ts.dll kopioitu C:\PHP kansiosta C:\Program Files\Apache Group\Apache2\bin kansioon
php.ini-dist tiedosto kopioitu ja uudelleen nimetty php.ini nimiseksi C:\WINDOWS kansioon.
kyseinen tiedosto näyttää tältä session asetuksien osalta:
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
; As of PHP 4.0.1, you can define the path as:
;session.save_path = C:/omat
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
session.save_path = c:/windows/temp
; Whether to use cookies.
session.use_cookies = 1
; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1
; Name of the session (used as cookie name).
session.name = PHPSESSID
; Initialize session on request startup.
session.auto_start = 0
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
; The path for which the cookie is valid.
session.cookie_path = /
; The domain for which the cookie is valid.
session.cookie_domain =
; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.
session.gc_probability = 1
session.gc_divisor = 100
Käytössä PHP versio 4.3.7, apache 2.0.50 palvelin ja Käyttöjärjestelmänä WINDOWS XP PRO.
Sessiot vaan eivät toimi!
Miten saada sessiot toimimaan?????
Vastaukset 1
Vanhimmat
Päivitä uusimpaan PHP:hen varmuuden vuoksi
Jossain noista uusista versioista oli session-tuki rikki. Tappelin itse pari viikkoa asian kanssa ennenkuin tajusin...
Tarkista että onko session.save_path olemassa ja muodostuuko sinne tiedosto kun ajat session_start(); metodia. Jos ei muodostu niin kyseessä saattaa olla käyttöoikeusongelma.
Tässäpä myös toimivat testiskriptit sessioille:
-------- sessiontest1.php -------------
Enter your Name:
-------- sessiontest2.php -------------
Step 3 - Test Session Part II
Hey Everything is still working!
Pick an option:
Let's delete this session value now. Click Here.
Let's destroy this session. Click Here.
------ sessiontest4.php --------
------ sessiontest5.php --------