localStorage 활용방법
페이지 정보
작성자
본문
<?
// Save an item to the local storage
function set_key($key, $data)
{
echo "<script language='Javascript'>localStorage.setItem('$key', '$data');</script>";
return $this;
}
// Get an item from the local storage (basic implementation)
function get_key($key)
{
echo "<script language='Javascript'>return localStorage.getItem('$key'));</script>";
}
// Remove an item from the local storage
function delete_key($key)
{
echo "<script language='Javascript'>return localStorage.getItem('$key');</script>";
}
// Clear the local storage
function clear_key()
{
echo "<script>localStorage.clear();</script>";
}
?>
<script>
function get_key(key) {
return localStorage.getItem(key);
}
</script>
<?
set_key("ck_mb_id", "test");
$tmp_mb_id = "<script>document.write(get_key('ck_mb_id'));</script>";
echo "당신의 아이디는?".$tmp_mb_id;
?>
댓글목록
등록된 댓글이 없습니다.