This file is indexed.

/usr/share/doc/python-myghty/html/session.html is in python-myghty 1.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
<html>
<head>
	<title>
Myghty Documentation
</title>
	<link href="style.css" rel="stylesheet" type="text/css"></link>
	<link href="syntaxhighlight.css" rel="stylesheet" type="text/css"></link>
</head>
<body>




<link href="docs.css" rel="stylesheet" type="text/css"></link>


<div style="position:absolute;left:0px;top:0px;"><a name="top"></a>&nbsp;</div>

<div class="doccontainer">

<div class="docheader">

<div class="docheadertext" >Myghty Documentation</div>
<div class="">Version: 1.1   Last Updated: 09/10/06 19:32:29</div>
</div>



		<A name="session"></a>
		
	
<div class="topnav">


	
	<div class="topnavcontrol">
	View: <b>Paged</b> &nbsp;|&nbsp; <a href="documentation.html">One Page</a>
	</div>



<div class="topnavsectionlink">

<a href="index.html">Table of Contents</a>

<div class="prevnext">
Previous: <a href="filtering.html">Filtering and Flushing (and Escaping)</a>

&nbsp; | &nbsp;


Next: <a href="cache.html">Data Caching</a>

</div>
</div>


<div class="topnavmain">
	<div class="topnavheader">Session</div>
	<div class="topnavitems">
	


    
    
    <div class="toclink">
        <A style="" href="#session_usage">Basic Usage</a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#session_options">Session Options</a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#session_methods">Session Methods</a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#session_members">Session Members</a>
    </div>
    
    <div class="toclinkcontainer">
    </div>


    
    
    <div class="toclink">
        <A style="" href="#session_object">Using the Session Object Standalone</a>
    </div>
    
    <div class="toclinkcontainer">
    </div>



	</div>
</div>

</div>

		<div class="sectioncontent">
			




<div class="subsection" style="margin-left:10px;">

    <div class="sectiontext">


<p>Myghty now has its own session storage class.  This class offers some advantages over the mod python session, including:</p>
<ul>
	<li>It is independent of mod_python, so it works with either version of Apache, other web connectors, and in CGI mode
	<li>The file-based version keeps each user's session in separate DBM files, so no synchronization issues are present
	between disparate sessions, session files are small, and old sessions can be cleaned up via an external file-deletion process.
	<li>The session object loads its data in immediately from the persistent store and unlocks, so that a page containing multiple session-enabled requests (i.e., such as a page with IFRAMEs or image delivery servlets) can allow access to all of its sub-elements with a minimum of waiting between the concurrent requests.
	<li>The package can also run directly with the mod_python request, independently of Myghty.
</ul>


			


			


			


			



			


    </div>

        



<A name="session_usage"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Basic Usage</span>
    <div class="sectiontext">


<p>The session is retrieved from the request object via the get_session() method, operated upon like a dictionary, and then can have its <span class="codeline">save()</span> method called to write its data to persistent storage:</p>


	

<div class="code">
<pre><span class="blocktag">&lt;%python scope="init"&gt;</span>
    <span class="python_comment"># get the session
</span><span class="python_operator">    </span><span class="python_name">session </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_session</span><span class="python_enclosure">()</span><span class="python_operator">
    </span>
    <span class="python_comment"># add data
    </span><span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'key1'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'foo'</span><span class="python_operator">
    </span>
    <span class="python_comment"># get data
    </span><span class="python_keyword">if </span><span class="python_name">session</span><span class="python_operator">.</span><span class="python_name">has_key</span><span class="python_enclosure">(</span><span class="python_literal">'user'</span><span class="python_enclosure">)</span><span class="python_operator">:
        </span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'user'</span><span class="python_enclosure">]</span><span class="python_operator">
    </span><span class="python_keyword">else</span><span class="python_operator">:
        </span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">User</span><span class="python_enclosure">()</span><span class="python_operator">
        </span><span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'user'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_name">user</span><span class="python_operator">
        </span>
    <span class="python_comment"># save new information
    </span><span class="python_operator"></span><span class="python_name">session</span><span class="python_operator">.</span><span class="python_name">save</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag">&lt;/%python&gt;</span></pre></div>


<p>The session handles generation of session IDs automatically as well as storing and retrieving them from cookies.  Options exist to pass in custom session IDs, to not use cookies, to use "signed" session IDs, and to change the cookie-based session key (defaulting to <span class="codeline">myghty_session_id</span>).  It loads its data in fully when instantiated and then unlocks, so no programmatic locking or unlocking is necessary (but lock methods are available if you want the session to stay locked throughout a request).</p>


    </div>


    <a href="#session" class="toclink">back to section top</a>


</div>


        



<A name="session_options"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Session Options</span>
    <div class="sectiontext">



	
<p>Session options are specified as Myghty configuration parameters in the form <span class="codeline">session_XXXX</span>, to identify them as options being sent to the Session object.   When calling the m.get_session() method, parameters may be specified with or without the "session_" prefix; they are stripped off. </p>

<p>The get_session method can take any of the configuration parameters that are identified below as used directly by the Session object or by the underlying Namespace objects.</p>


	
	<table cellspacing="0">
	

	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_cookie_expires"></a>
	<b>session_cookie_expires</b> (boolean, datetime, timedelta)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: True<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The expiration time to use on the session cookie.  Defaults to "True" which means, dont specify any expiration time (the cookie will expire when the browser is closed).  A value of "False" means, never expire (specifies the maximum date that can be stored in a datetime object and uses that).  The value can also be a datetime.timedelta() object which will be added to the current date and time, or a datetime.datetime() object.
	</p>

	</td>
</tr>




	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_data_dir"></a>
	<b>session_data_dir</b> (string)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The data directory where sessions will be stored.  If this argument is not present, the regular
	<a href="params.html#parameters_data_dir" >data_dir</a> parameter is used, with the path "./sessions" appended to it.
	</p>

	</td>
</tr>



	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_dbmmodule"></a>
	<b>session_dbmmodule</b> (dbm module)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: anydbm<br/>
		used by: DBMNamespace
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	When dbm is used as the session type, this parameter points to a module to use for DBM support, such as gdbm, dbhash, etc.
	</p>

	</td>
</tr>



	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_id"></a>
	<b>session_id</b> (String)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Session id for this session.  When using sessions with cookies, this parameter is not needed as the session automatically creates, writes and retrieves the value from the request.  When using a URL-based method for the session, the id should be retreived from the <a href="session.html#session_members_id" >id</a> data member when the session is first created, and then used in writing new URLs.
	</p>

	</td>
</tr>


	
	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_invalidate_corrupt"></a>
	<b>session_invalidate_corrupt</b> (boolean)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: False<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	<p>If there are any exceptions upon loading the session, the entire session will be invalidated and started clean.  When object interfaces change in an application, old versions of those objects might still be present in existing session files, and exceptions will be raised when the session object tries to deserialize them into memory.  Setting this to True allows those sessions to be cleaned out and started from scratch again.</p>
	
	<p>This parameter should be used carefully since it can conceal real application errors in certain situations.</p>
	</p>

	</td>
</tr>




	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_key"></a>
	<b>session_key</b> (string)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: myghty_session_id<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The key that will be used as a cookie key to identify sessions.  Changing this could allow several different applications to have different sessions underneath the same hostname.  
	</p>

	</td>
</tr>



	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_log_file"></a>
	<b>session_log_file</b> (file)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	A file or buffer object where debugging information will be sent.
	</p>

	</td>
</tr>



	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_namespace_class"></a>
	<b>session_namespace_class</b> (class)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	A class that will be used to create the underlying NamespaceManager used by this Session, when a custom NamespaceManager implementation is being used.  By default, the implementation is determined among the built-in NamespaceManagers by the <a href="session.html#session_options_session_type" >session_type</a> parameter.  
	</p>

	</td>
</tr>



	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_type"></a>
	<b>session_type</b> (string)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: dbm<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	<p>Type of storage used for the session, current types are "dbm" (also called "file"), and "memory".  The storage uses the Container API that is also used by the cache system.
	</p>
	<p>
	When using dbm files, each user's session is stored in its own dbm file, via the class <span class="codeline">myghty.container.DBMNamespaceManager</span> class.  To get the dbm filename used by a session, use <span class="codeline">session.namespace.file.path</span>, or to retrieve a list of the actual files created by the particular dbm instance, use <span class="codeline">session.namespace.file.get_filenames()</span>.
	
	</p>
	</p>

	</td>
</tr>



	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_secret"></a>
	<b>session_secret</b> (string)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Secret key to enable encrypted session ids.  When non-None, the session ids are generated with an MD5-signature created against this value.
	</p>

	</td>
</tr>



	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_session_timeout"></a>
	<b>session_timeout</b> (integer)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Time in seconds before the session times out.  A timeout occurs when the session has not been loaded for more than timeout seconds.
	</p>

	</td>
</tr>



	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_session_use_cookies"></a>
	<b>session_use_cookies</b> (boolean)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: True<br/>
		used by: Session
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Whether or not to store and retrieve the session ID from the cookies present in the request.  If False, the session ID must be present in the argument list to retrieve an existing session.
	</p>

	</td>
</tr>



	
        
<tr class="light">
	<td valign="top">
	<A name="session_options_use_modpython_session"></a>
	<b>use_modpython_session</b> (boolean)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: ApacheHandler
		</div>
	</td>
</tr>

<tr class="light">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Instructs the get_session() method, or the global variable <i>s</i> if configured, to return an instance of the mod_python session object instead of the Myghty session object.  If this is configured, only the <a href="session.html#session_options_session_timeout" >session_timeout</a> parameter is supported.
	</p>

	</td>
</tr>



	
        
<tr class="dark">
	<td valign="top">
	<A name="session_options_use_session"></a>
	<b>use_session</b> (boolean)</td>
	<td align="right" width="40%">
		<div style="text-align:left">
		default: None<br/>
		used by: ApacheHandler,CGIHandler
		</div>
	</td>
</tr>

<tr class="dark">
	<td colspan="2">
	<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Establishes the global variable <i>s</i> as a reference to the Session object.  This means all requests will automatically have the session initialized and loaded.  If an application has a lot of templates that dont have use for the session, this could add unnecessary overhead.
	</p>

	</td>
</tr>




	
	</table>


    </div>


    <a href="#session" class="toclink">back to section top</a>


</div>


        



<A name="session_methods"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Session Methods</span>
    <div class="sectiontext">


	
	<table cellspacing="0">
	

	
		<tr class="light">
	<td>
	<A name="session_methods_delete"></a>
	<b>delete()</b></td>
	</td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	deletes the persistent storage for this session, but the session remains valid.  When save() is called, the new data will be written.
	
	</div>
	
	</td>
	</tr>

	
		<tr class="dark">
	<td>
	<A name="session_methods_invalidate"></a>
	<b>invalidate()</b></td>
	</td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	invalidates this session, creates a new session id, returns to the is_new state
	
	</div>
	
	</td>
	</tr>

	
		<tr class="light">
	<td>
	<A name="session_methods_load"></a>
	<b>load()</b></td>
	</td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Loads the data from this session from persistent storage and updates the last modified time of the session.  This method is called automatically upon session object construction and does not need to be called explicitly.  If the session's persistant storage does not exist, it will be created.  If the session has not been accessed since the timeout period, the invalidate() method will be called, and the session will return to the is_new state, as well as was_invalidated.
	
	</div>
	
	</td>
	</tr>

	
		<tr class="dark">
	<td>
	<A name="session_methods_lock"></a>
	<b>lock()</b></td>
	</td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Locks this session against other accesses.  This method is called automatically by the load() and save() methods.  However, this method can be called to keep the session locked persistently until explicitly unlocked by the unlock() method.
	
	</div>
	
	</td>
	</tr>

	
		<tr class="light">
	<td>
	<A name="session_methods_unlock"></a>
	<b>unlock()</b></td>
	</td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Unlocks this session against other accesses.  This method is called automatically by the load() and save() methods.  However, this method can be called to unlock a persistent lock set up by the lock() method.
	
	</div>
	
	</td>
	</tr>

	
		<tr class="dark">
	<td>
	<A name="session_methods_save"></a>
	<b>save()</b></td>
	</td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	Saves the data for this session to persistent storage.  This should be called whenever you know the session has been modified.
	
	</div>
	
	</td>
	</tr>


	
	</table>


    </div>


    <a href="#session" class="toclink">back to section top</a>


</div>


        



<A name="session_members"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Session Members</span>
    <div class="sectiontext">


	
	<table cellspacing="0">
	

	
		<tr class="light">
	<td>
	<A name="session_members_accessed"></a>
	<b>accessed</b></td>
	</td><td></td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The last time this session was accessed.
	
	</div>
	
	</td>
	</tr>


	
		<tr class="dark">
	<td>
	<A name="session_members_created"></a>
	<b>created</b></td>
	</td><td></td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The time this session was created.
	
	</div>
	
	</td>
	</tr>


	
		<tr class="light">
	<td>
	<A name="session_members_id"></a>
	<b>id</b></td>
	</td><td></td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	<p>The id for this session.  When using cookies, this is retrieved and set within the cookie referenced by the <a href="session.html#session_members_key" >key</a> string.  The id is automatically created when a new session is instantiated.</p>
	<p>
	When regular cookies are used (the default), this value is the same value sent in the session cookie to the client.  When signed cookies are enabled via the <a href="session.html#session_options_session_secret" >session_secret</a> parameter, this id is MD5 signed against the secret to form the client cookie value.
	</p>
	
	</div>
	
	</td>
	</tr>


	
		<tr class="dark">
	<td>
	<A name="session_members_is_new"></a>
	<b>is_new</b></td>
	</td><td></td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	True if this session was newly created.  This can be because no previous session existed,
	or the session existed but was invalidated, usually due to a timeout.
	
	</div>
	
	</td>
	</tr>


	
		<tr class="light">
	<td>
	<A name="session_members_key"></a>
	<b>key</b></td>
	</td><td></td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The key used in cookies to set this session's id.  
	
	</div>
	
	</td>
	</tr>

	
		<tr class="dark">
	<td>
	<A name="session_members_secret"></a>
	<b>secret</b></td>
	</td><td></td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	
	
	</div>
	
	</td>
	</tr>

	
		<tr class="light">
	<td>
	<A name="session_members_timeout"></a>
	<b>timeout</b></td>
	</td><td></td>
	</tr>
	<tr class="light">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	The timeout span of this session.
	
	</div>
	
	</td>
	</tr>

	
		<tr class="dark">
	<td>
	<A name="session_members_was_invalidated"></a>
	<b>was_invalidated</b></td>
	</td><td></td>
	</tr>
	<tr class="dark">
	<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
	True if this session was invalidated upon opening, usually due to a timeout.   <a href="session.html#session_members_is_new" >is_new</a> will always be True as well.
	
	</div>
	
	</td>
	</tr>


	
	</table>

	

    </div>


    <a href="#session" class="toclink">back to section top</a>


</div>


        



<A name="session_object"></a>

<div class="subsection" style="margin-left:20px;">

    <span class="sectionheadertext">Using the Session Object Standalone</span>
    <div class="sectiontext">


<p>The session object is actually functionally independent of the rest of Myghty, and is compatible with the mod python request object directly, as well as the request emulator used by CGIHandler.  To instantiate it, simply use its constructor as follows:</p>

	

<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">session </span><span class="python_keyword">import </span><span class="python_name">Session</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">:
    </span><span class="python_name">session </span><span class="python_operator">= </span><span class="python_name">Session</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_operator">, </span><span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/session_dir'</span><span class="python_operator">, </span><span class="python_name">key</span><span class="python_operator">=</span><span class="python_literal">'user_session_id'</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>

	
<p>The full constructor signature for the Session object is as follows:</p>
	

<div class="code">
<pre><span class="python_name">Session</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_operator">, </span><span class="python_name">id </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">use_cookies </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">, </span>
    <span class="python_name">invalidate_corrupt </span><span class="python_operator">= </span><span class="python_name">False</span><span class="python_operator">,</span>
    <span class="python_name">type </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span>
    <span class="python_name">key </span><span class="python_operator">= </span><span class="python_literal">'myghty_session_id'</span><span class="python_operator">, </span><span class="python_name">timeout </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span>
    <span class="python_name">secret </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">log_file </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>

<p>Note that the parameters are the same as the configuration arguments with the prefix "session_" removed.</p>


    </div>


    <a href="#session" class="toclink">back to section top</a>


</div>




    
<div class="sectionnavblock">
<div class="sectionnav">


        Previous: <a href="filtering.html">Filtering and Flushing (and Escaping)</a>

                |

        Next: <a href="cache.html">Data Caching</a>

</div>
</div>


</div>


		</div>






</div>

















<center>
</center>
</body>
</html>