跳到主要內容

使用jQuery的Plugin管理cookie

為了能在javascript上管理cookie,因此採用了jQuery的Plugin:jQuery.Cookie

如何使用呢?

上面的連結是連到github,可以看到有個README.md檔案,裡面有說明如何使用。
以下是範例內容
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
//Create session cookie:
$.cookie('the_cookie', 'the_value');

//Create expiring cookie, 7 days from then:
$.cookie('the_cookie', 'the_value', { expires: 7 });

//Create expiring cookie, valid across entire site:
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });

//Read cookie:
$.cookie('the_cookie'); // => "the_value"
$.cookie('not_existing'); // => null

//Delete cookie:
// Returns true when cookie was found, false when no cookie was found...
$.removeCookie('the_cookie');
// Same path as when the cookie was written...
$.removeCookie('the_cookie', { path: '/' });

這時候就可用PHP印出cookie,確認是否有成功。
1
2
3
<?php
var_dump($_COOKIE);
?>

(其實這篇文章主要是記錄jQuery.Cookie的連結XD)

留言

這個網誌中的熱門文章

Android開啟Facebook App

如果手機裡已經安裝了Facebook,為什麼還要開啟瀏覽器重新輸入帳密呢? 直接用Facebook操作不是比較方便呢? --以上是前言--XD 所以為了方便已經安裝Facebook使用者,所以App裡開啟粉絲專頁時,應該會有兩種方式 範例如下: ... public static void openFacebookPage (Context context, String id) { Intent intent = null ; try { context. getPackageManager (). getPackageInfo ( "com.facebook.katana" , 0 ); String uri = "fb://page/" + id; intent = new Intent(Intent. ACTION_VIEW , Uri. parse (uri)); } catch (Exception e) { String uri = "https://www.facebook.com/pages/1/" + id; intent = new Intent(Intent. ACTION_VIEW , Uri. parse (uri)); } context. startActivity (intent); } ... 參考資料: android - launch facebook app from other app - Stack Overflow php - Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to "Allow" the applicati...

What is phpize

What is phpize According to the PHP official document : The phpize command is used to prepare the build environment for a PHP extension. If you need to build such an extension that from github or another code repositories, you can use  build tools to perform the build manually. 

AndroidManifest的小技巧

當在設定推播時,在  AndroidManifest.xml  上需要指定不同application id時該怎麼辦呢?(可能會有xxx.yyy.com.debug與xxx.yyy.com兩個版本) 有個簡單的小技巧可以實現這件事情。 <permission android:name= "${applicationId}.permission.C2D_MESSAGE" android:protectionLevel= "signature" /> <uses-permission android:name= "${applicationId}.permission.C2D_MESSAGE" /> 參考資料: Using build types in Gradle to run same app that uses ContentProvider on one device