How to define a non-database relationship for the Views module Basically, I have an array of nids (node ids) stored in a $_SESSION variable, which is updated according to user actions (it holds a history of visited node pages). 
Now, I would like to create a view which displays a list of nodes, filtered by nids given in a $_SESSION variable. 

For example:
if $_SESSION['my_nids'] == [1,5,6]
=> I want to display nodes 1,5,6 in the view. 

Storing the nids in a db table is not an option due to performance reasons.

Can someone point me how to create such a non-database relationship views handler?
You can use the views php module. And you can get the $_SESSION['my_nids'] with in view. Actually you can do anything there that can be done with PHP.

Please note that this will again have a performance hit if the code is large. for simple things you go this route.