she has memory issues and doesn’t know.
That is not pleasant, maybe you can assist her to take the following action:
Has she forgotten her Apple ID?, -> Check your Apple ID via your email box, see this Apple article: If you forgot your Apple ID -> If you forgot your Apple ID email address or phone number - Apple Support
OR see -> Having trouble signing in?
https://iforgot.apple.com/password/verify/appleid
See also -> If you can't connect or sign in to iCloud
If you can't connect or sign in to iCloud - Apple Support
Has she forgotten her password? -> See this Apple article: If you forgot your Apple ID password
If you forgot your Apple ID password - Apple Support
-----
Then your grandma has to read -> this Apple article: What to do before you sell, give away, or trade in your iPhone, iPad, or iPod touch
What to do before you sell, give away, or trade in your iPhone or iPad - Apple Support
Then she has to remove the iPhone from her account, see this Apple article:
Check your Apple ID device list to see where you're signed in
Check your Apple ID device list to find where you're signed in - Apple Support
Then you can sign in with your own Apple ID.
See the following Apple articles:
Activation Lock for iPhone, iPad, and iPod touch
Activation Lock for iPhone, iPad, and iPod touch - Apple Support
How to remove Activation Lock
How to remove Activation Lock – Apple Support (UK)
You can also contact Apple support for help, -> Get Support (apple.com)
You have to show proof of ownership of your product, provide all documentation showing your purchase of the device.
If you do not have additional proof of ownership, contact the reseller. They may be able to provide the original purchase document.
Once Apple receive your proof of ownership, Apple will further review your request and provide an update.
If you still need help, get more help and assistant from Apple directly, see Contact Apple for support and service -> Contact Apple for support and service – Apple Support (UK)