$.data(), Session Variable, or Cookie?

$.data(), Session Variable, or Cookie?

I'm working on some code that allows a user to login to access certain portions of the site.

I want to pass the UID to a function and then from the function make a call to a server side PHP script to retrieve data to populate Firstname, Lastname, and Password fields on a form.
I already know how to do this.

I know that I can store the UID in a cookie or a session variable and then retrieve the value from within my function.

Cookies can be a problem. If I use a session variable then the app has to make another call to a PHP script to retrieve the value.

I am wondering if there is anything 'wrong' with storing the UID like this:
  1. $("div#data).data("UID",UID)

The <div id="data"> would always be present within the DOM. I'm not loading different pages. All dynamic content is handled via $.load().

I can then read the value from within the function and not have deal with cookies or do a server side lookup.

What are the pros and cons of using $.data() like this? This technique 'feels' like I'm using $.data() as a global variable in the DOM. Is that's intended purpose? Is this good or bad and should I be doing something different?

Am I missing something obvious? What could possible go wrong?