As a beginner in JSP I noticed that we can hold any value inside of a session, while cookie can have value only of type String. I found it weird because what if someone wants to hold type other than String in Cookie?
- Session:
setAttribute(String name, Object value)
Binds an object to this session, using the name specified.
- Cookie:
Cookie(String name, String value)
Constructs a cookie with a specified name and value.
Can someone from community help me understand it? Why we can't store anything inside Cookie except String, while we can inside Session's labels?
Or from a different perspective, why should cookie hold only String value?