Title: PHP::Session
1PHPSession
- Tatsuhiko Miyagawa
- ltmiyagwa_at_bulknews.netgt
- Livin On The EDGE, Co.,Ltd.
- 2003/01/31 Shibuya.pm Technical Talks
2???
- PHPSession ??
- ???????
- PHP????????
- PHPSession ???
- ????
- ?????
3PHPSession ??
DESCRIPTION PHPSession provides a way to read /
write PHP4 session files, with which you can make
your Perl Application session shared with
PHP4. PHPSession ? PHP4 ????????????????????????
??????Perl ???????????????PHP4????????????
4???????
?????????(??
5????????
- ???????PHP????????
- PHP???????
- ???????????
Perl ?? PHP????????!
6PHP????????
- PHP3 ???PHPLIB ?????????????
- PHP4 ???????????????????????? (PHPLIB?????)
- ????PHP4???
7PHP4??????????
- /tmp/sess_SESSION_ID ??????????????(????????)
- ????? flock ???
- ?????????????
bazO3"foo"2s3"bar"s2"ok"s3"yes"s4
"done"arra1i3O3"foo"2s3"bar"s2"o
k"s3"yes"s4"done"!foo
8???????????
Object
????
???
????
bazO3"foo"2s3"bar"s2"ok"s3"yes"s4
"done"arra1i3O3"foo"2s3"bar"s2"o
k"s3"yes"s4"done"!foo
9??????????? (cont.)
?
string
??
string
??
?
bazO3"foo"2s3"bar"s2"ok"s3"yes"s4
"done"arra1i3O3"foo"2s3"bar"s2"o
k"s3"yes"s4"done"!foo
10??????????? (cont.)
???
array
int
bazO3"foo"2s3"bar"s2"ok"s3"yes"s4
"done"arra1i3O3"foo"2s3"bar"s2"o
k"s3"yes"s4"done"!foo
?
11??????????? (cont.)
bazO3"foo"2s3"bar"s2"ok"s3"yes"s4
"done"arra1i3O3"foo"2s3"bar"s2"o
k"s3"yes"s4"done"!foo
undef
12??????
a1 "foo" a2 new baz a3
"bar" a4 -1.2 data'hi'
'foo' data'foo' "bar"
13???????????
my var_re '(\w)\' my str_re
's\d"(.?)"' my int_re 'i(-?\d)' my
dbl_re 'd(-?\d(?\.\d)?)' my arr_re
'a(\d)' my obj_re 'O\d"(.?)"\d' my
nul_re '(N)' my bool_re 'b(01)'
14???????????(cont.)
- ???????????
- ?????????? (5.6 ?????)
- PHP ?????1????????
- Perl ?????
- ParseRecDescent
- ?? (ParseFastDescent?)
- ???????
lt??gt?Perl?????????????lt/??gt
15??????????? (cont.)
- TextBalanced ???
- Damian Conway ?
- ParseRecDescent ????
- ???????????????
- ????????????OK
my bracket extract_bracketed(data, '')
16PHPSession ???
- Serializer ?Pluggable??????
- PHP ?? WDDX ????? (PHPSession ????????
WDDX.pm????????) - Strategy Pattern
- sess_ ??????????error
- create gt 1 ????????
17API
use PHPSession my session
PHPSession-gtnew(id) session id my id
session-gtid get/set session data my foo
session-gtget('foo') session-gtset(bar gt
bar) remove session data session-gtunregister
('foo')
18API (cont.)
remove all session data session-gtunset
check if data is registered session-gtis_registere
d('bar') save session data session-gtsave
destroy session session-gtdestroy
19PHP???
- PHP????Perl?????
- Perl(??) gt PHP (??) gt Perl(????)
- PHP???????? PHPSessionObject ???? bless
- _class ???PHP?????????
20ApacheSessionPHP
- ApacheSession
- ??????????????
- Store, Lock, Generate, Serialize
- Serialize ? Store ????????
- Serialize PHPSession ???
- Store ???????? PHP?????(sess_SESSION_ID)
tie session, ApacheSessionPHP
21????
- ???????????
- Bug Report ? Patch ???????
- Y! inc ???(?)
- PHP????????????????
- ????????????????
- PHP?Web???????????????
- ????????????
22??????????
use ApacheCookie use ApacheRequest use
DigestMD5 qw(md5_hex) use PHPSession my r
ApacheRequest-gtnew(Apache-gtrequest) my sid
get_sid() gen_sid() my sess
PHPSession-gtnew(sid, create gt 1
) sess-gtset(name gt 'miyagawa') sess-gtset(ema
il gt 'miyagawa_at_bulknews.net') sess-gtsave()
23?????????? (cont.)
my cookie ApacheCookie-gtnew(r, -name gt
'PHPSESSID', -value gt sid, -path gt
'/', ) cookie-gtbake r-gtinternal_redirect("/php
-session/index.php") sub get_sid my
cookies ApacheCookie-gtfetch return ?
cookiesPHPSESSID ? cookiesPHPSESSID-
gtvalue undef
24?????????? (cont.)
lt?php session_start() ?gt Name lt? name
?gtltbrgt Email lt? email ?gtltbrgt SID lt?
PHPSESSID ?gt
25?????
- PHPSessionMySQL
- ?????? MySQL ?????
- WDDX ????
- TestPHP
- InlinePHP
- TomcatSession