<?php /** * Session Class * * Created on 2011. 11. 16. * @author 불의회상 <hoksi2k@hanmail.net> * @package library * @subpackage controllers * @version 1.0 */ class Session_lib extends CI_Controller { function __construct() { parent::__construct(); $this->load->library('session'); $this->load->helper('url'); } function index() { $this->session->set_userdata('session_date', date('세션이 시작된 시간 : Y-m-d H:i:s')); redirect('session_lib/load'); } function save() { $this->session->set_userdata('session_test', $this->input->post('custom_session')); redirect('session_lib/load'); } function load() { $data['session_date'] = $this->session->userdata('session_date'); $data['session_test'] = $this->session->userdata('session_test'); $data['session_array'] = $this->session->all_userdata(); $this->load->view('session_lib_sample', $data); } function del($name = NULL) { if($name != NULL) { $this->session->unset_userdata('session_test'); } else { $this->session->sess_destroy(); } redirect('session_lib/load'); } }
<?php $this->load->view('inc/header')?> <table class="tablesorter" border="0" cellpadding="0" cellspacing="1"> <thead> <tr> <th style="text-align:center" colspan="2">Session</th> </tr> </thead> <form action="<?=site_url('session_lib/save')?>" method="post"> <tr> <td>Session 저장</td> <td><input type="text" name="custom_session" value="<?=time() . ' : TESTED'?>"> <input type="submit"></td> </tr> </form> <tr> <td>session_test 삭제</td> <td><input type="button" value="Session 삭제" onclick="document.location.replace('<?=site_url('session_lib/del/session_test')?>');"></td> </tr> <tr> <td>모든 Session 삭제</td> <td><input type="button" value="Session 삭제" onclick="document.location.replace('<?=site_url('session_lib/del')?>');"></td> </tr> <thead> <tr> <th style="text-align:center" width="20%">세션</th> <th width="80%">결과</th> </tr> </thead> <tr> <td>$this->session->userdata('session_date')</td> <td><?php echo $session_date?></td> </tr> <tr> <td>$this->session->unset_userdata('session_test')</td> <td><?php echo $session_test?></td> </tr> <tr> <td>$this->session->all_userdata()</td> <td><xmp><?php print_r($session_array)?></xmp></td> </tr> </table> <?php $this->load->view('inc/footer')?>
© Copyright by hoksi(Page rendered in 0.0070 seconds)