# cookie 跟session的差別 Http協議是無狀態協議,每次請求都不會紀錄上次執行的動作,為了方便判斷使用者的瀏覽、登入等狀態,可利用Cookie及Session的設定來紀錄。 | Tables | Cookie |Session | | ------------- |:-------------:| -----:| | 儲存位置 | 瀏覽器Client | 伺服器Server | | 常見用法 | <ol><li>儲存和追蹤使用者行為</li><li>儲存用戶登入、購物車等伺服器所需的資訊</li><li>儲存使用者設定和偏好等</li></ol> | 將使用者相關的敏感資訊存放在伺服器端,每個使用者都有獨特的Session ID儲存在Cookie中 | ### Cookie實例 ```java //創建Cookie實體並紀錄使用者 Cookie cookie = new Cookie("user","Johnny"); //將Cookie加入給Server的回應 response.addCookie(cookie); //儲存期限設定為一個月 cookie.setMaxAge(60*60*24*30); //設定網域 cookie.setDomain("https://tw.chowsangsang.com"); ``` ### Session實例 ```java //取得HttpSession物件 HttpSession session = request.getSession(); //儲存使用者資訊 request.getSession().setAttribute("email", "johnny@mail.com"); //取回使用者資訊 request.getSession().getAttribute("email"); //登出時使session失效 request.getSession().invalidate(); ``` # inner join 跟 outer join的差異 - **inner join** A 和 B 獲得的是A和B的交集(intersect),即兩圈相交的部分,只會傳回滿足資料列聯結條件 (ON 之後) (Join Condition) 的資料列,其他不符合的資料列將不會顯示。 - **outer join** A和B獲得的是A和B的聯擊(union), 兩圈的所有部分。除了滿足連結條件的資料列會顯示外,在另一邊資料表存在的資料列也會顯示在結果集中,因此輸出項目可能有多筆會顯示 NULL。 # 如何在訂單中撈出各個會員的訂單明細 ```sql SELECT * FROM Orders INNER JOIN Customers ON Customers.CustomerID = Orders.CustomerID; ``` # 多型 在我個人專案中的應用,以會員系統為例,在Customers 類中包含會員屬性及checkOut()方法,Vip類繼承了Customer類中的所有屬性及方法,但在checkOut()方法中有自己的折扣計算方式。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up