Remembering last State

Hello Everyone!!
I have built a car alarm with Atmega328p-pu and I think it's time to upgrade the code. The thing is that in case the power source for any reason will disconnect and reconnect the microcontroller will go off and it will lose the state (on or off) and some other information that it keeps till I unlock it.

Is any way to program it remembering the last state(e.g I enable the alarm,power goes off after a while comes back on then the microcontroller will automatically will go on again)

Is any way not to use eeprom because has limitations?
If there isn't can I make it work if I place on the alarm an external sd card?

Thank you for the time!

You can certainly use the EEPROM for this. What limitations are you worried about? You can also write this info to an SD card and when the 328 powers up, it can go look for a file on the card and read the information back in (or default to something if the card and/or file are not present)

Eeprom has a number of writes.. because I want it to last I don't want someday soon stop working..I'm here if is it is a way to change e.g. a number from 0 to 1 or something like that that would not affect the atmega writes.If it's not I probably will go with the Idea of placing an sd on it.

Eeprom has a number of writes..

A limit of about 100,000 for each cell

How many times do you anticipate turning off the alarm ?

If you turn the alarm on or off ten times a day and write a single EEPROM location each time, that location will only last 10,000 days (over 27 years). Will that be long enough? If not, you can use multiple EEPROM locations to extend the life.

I know it's a long time but I want it to last. Plus that if the time comes that means if the battery then goes off this will be a weak spot..I will probably do this till I find a better solution.
Do you know any similar tutorial to help me about?

How many times a day do you anticipate the alarm being turned on and off ?

Let say you want to pass 20 parameters. That is 20 EEPROM cells. Then, if you address the cells in sequence (each time the next 20 and over from beginning), your 27 years (as told above) come 27 *50 = 1350 years

Is this ok?

(50 comes from 1kbyte eeprom and 20 “byte” parameters)

demkat1:
Let say you want to pass 20 parameters. That is 20 EEPROM cells. Then, if you address the cells in sequence (each time the next 20 and over from beginning), your 27 years (as told above) come 27 *50 = 1350 years

Is this ok?
(50 comes from 1kbyte eeprom and 20 “byte” parameters)

That only works if you have a way of storing which set of bytes your parameters are stored in.
For saving a single bit, at startup or reset:
Read EEPROM address 0. If the value is 0, read the next EEPROM address. Repeat until you find a non-zero byte. The top bit is your value and the bottom 7 bits are the number of times the byte has been written.
When you need to change the value, you know the address and the number of times it has been written. Increment the number of times it has been written. If the result is <= 0x7F store the write count and data bit in (address). If the result is greater than 0x7F (127), store the data bit plus a write count of 1 to ((address+1) % 1024) and store a 0 at (address). This spreads the wear over all 1024 locations so the EEPROM won’t wear out for over 27000 years (assuming ten updates a day, every day).