在页面刷新时存储值

Is there any way to store the value in session on page refresh?

For e.g. If I write the "abc" in textbox, and when I refresh the page, it will store in session.

Updated: Actually, If I write the "abc" in textbox then I will go on 2nd page of pagination without ajax (that is on-loading). When I come back to 1st page, the value of textbox remain.

This is what I want to say.

What have you tried so far? It's very basic question

just session_start(); and $_SESSION['abc'] = $_POST['abc']; if you send it via post and

<input `name="abc" value="<?= isset($_SESSION['abc']) ? $_SESSION['abc'] : 'default value' ?>" >`;

Edit:

If you hit f5 it won't be send as POST, you could check if f5 is hit and send it VIA ajax or you could send input after blur event when input is not empty, there are many possiblities. Check capturing f5 keypress event in javascript using window.event.keyCode in window.onbeforeunload event is always 0 and not 116

Also the other option is to save value in JavaScript in cookie after value is entered or input is blured and then when you are back on the site check if this value exists and show it.

I don't think this is possible. A refresh happens on the client side. Without any requests send to the server to be able to process.

To get a request to your server you either need a post or a get and refresh is neither of them.

AS @Robert already suggested in his comment, you will need more then just php to solve your problem (i.e. ajax)

im not sure i just found this maybe it can help you. You can use jquery and ajax. Using jquery you can detect if page is refreshed

$('body').bind('beforeunload',function(){
   //get your textbox value and send it to php file and you can start your session there.
});

Link