-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.sql
More file actions
executable file
·77 lines (55 loc) · 1.76 KB
/
Copy pathsession.sql
File metadata and controls
executable file
·77 lines (55 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
concept _session;
method '_session.register',interface;
method '_session.setcookie', _session;
if not exists (select * from systable
where table_name='_session' and creator=user_id('_session'))
then
create table _session._session (
id uniqueidentifier,
username varchar(128) not null,
useragent long varchar,
primary key (id)
);
create view interface._session
as select * from _session._session;
grant select, update on interface._session to interface;
end if;
alter procedure _session.setCookie (
name varchar(250),
value long varchar,
max_age integer,
path varchar(250) default '/' )
begin
call dbo.sa_set_http_header( 'Set-Cookie',
name + '=' + value
+ ';'+
' max-age=' + string( max_age )
+ ';'+
' path=' + path
+ ';' +
-- ' expires=' + '8h'
''
);
end;
alter function _session.register ()
returns uniqueidentifier
begin
if nullif(connection_property('sessionid'),'') is null then
create variable _session_username varchar(128);
create variable _session_id uniqueidentifier;
create variable _session_device varchar(32);
set _session_id = newid();
set _session_username = http_variable('username');
set _session_device = if http_header('user-agent') like '%iPod;%' then
'ipod'
else 'pc'
endif
;
insert into _session (id, username, useragent)
values (_session_id, _session_username, http_header('user-agent') )
;
call sa_set_http_option('sessionid', _session_id );
end if;
call setCookie ('xml_sessionid', _session_id, 4200, '/xml');
return _session_id
end;