How electron starts when it reestablish the connection?

if the connection of electron to cloud is lost and when it reestablishes the connection to cloud on available of network then contents of variables in application code are lost or retained…
no any sleep modes are used for this application and no system modes used (automatic mode only)

On a mere connection loss - with subsequent reconnection - variables are not lost

I’ve noticed when the router does its dhcp renewal, the particle photon reboots , so I also lose variable data.
Would this be the code or firmware issues?

That’s most likely a code issue where the code does not react gracefully to a connection loss.
And this should be addressed first.

But in order to keep your variables intact even across a reset you could mark them retained