[session_vars]

Description

Link: [session_vars]
Author: Jason Huck
Category: Session
Version: 8.x
License: Public Domain
Posted: Feb. 10, 2006
Updated: Feb. 11, 2006
More by this author...
This tag, based on code posted by Adam Randall here, returns a pair array containing the variables within the given session. The tag must be loaded via LassoStartup, and will only return results when the value of [session_result] is "load."  Otherwise returns "Undefined." Currently works with "Local Default" (SQLite) or "External" (MySQL) sessions. "In-Memory" sessions are not supported.

Parameters

none


Sample Usage

// display all the vars in the session with their values

if(session_vars('mySession') != 'Undefined');
	iterate(session_vars('mySession'), local('i'));
		#i->first + ': ' + #i->second + '<br>';
	/iterate;
/if;
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
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
define_tag(
	'vars',
	-namespace='session_',
	-required='name',
	-priority='replace',
	-privileged,
	-description='Returns an array of all the variables in the given session.'
);
	local(
		'in' = null,
		'out' = array,
		'key' = ('_SessionTracker_' + #name + '_' + session_id( -name=#name))
	);
	
	local('sql' = '
		SELECT data 
		FROM global_prefs 
		WHERE store_key = \'lasso_session_database\'
	');
	
	inline(
		-database='lasso_internal',
		-sql=#sql
	);
		local('dbname') = field('data');
	/inline;


	local('sql' = '
		SELECT data 
		FROM global_prefs 
		WHERE store_key = \'lasso_session_table\'
	');
	
	inline(
		-database='lasso_internal',
		-sql=#sql
	);
		local('tblname') = field('data');
	/inline;
	
	local('sql' = '
		SELECT * 
		FROM ' + #tblname + ' 
		WHERE session_key = \'' + #key + '\'
	');
	
	inline(
		-database=#dbname,
		-sql=#sql
	);			
		if(found_count);
			protect;
				local('data') = field('data');
				#data = decompress(#data);
				#in->unserialize(#data);

				if(#in->isa('map'));
					iterate(#in->keys, local('i'));
						#out->insert(#i = #in->find(#i));
					/iterate;
				else;
					return('Undefined');
				/if;
				
				handle_error;
					return('Undefined');
				/handle_error;
			/protect;
		/if;
	/inline;
	
	return(#out);
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net