The distinct keyword is generally used for rows where the target value is **not** distinct and there may be multiple rows with that value. Isn't your uniq_id already unique in this table? Maybe not . . . in any case there are ways to do this without needing distinct.
Actually what i want is i need to retrieve last added distinct record(uniq_id) from table...but its randomly retriving
What value do you have to determine "last added?" Usually there is (should be!) a datetime value for the added date, which makes this easier. If not, assuming that table.id is an auto increment field,
$query = "select productid from user='$_SESSION[user]' order by date_added desc limit 1";
$query = "select productid from user='$_SESSION[user]' order by id desc limit 1";
or limit 4 as you originally have it . . . anyway every row should have a unique identifier (and a datetime field) and this becomes very easy.