I have php questions..please give me some ideas...
1. how can I destroy php session if the browser is close?
2. if i have textboxes and it contains data from the database. how can i destroy or expire the data the moment i press back in the browser.
3. in a textbox, when i have used the text box type some numbers and letters on it. If I have finished processing it, the next time i enter another entry, a drop down with my previous inputs will appear...how do i remove it (except pressing delete) to remove it permanently.
4. How to do this:

$string='HELLO';

I wanted to output only HEL and remove the remaining letters.

Recommended Answers

All 4 Replies

1/2 You'll need to trap the browser event with Javascript (onbeforeunload).
3. Is a browser setting.
4. See substr.

Careful not to mix up client behaviour and serverside behaviour. With PHP, the session lives until PHP expires the session or it is manually purged by your code. When a browser is closed, it will delete any session cookies in its cache which includes the cookie that was created by your PHP script to identify the serverside session. When it launches, it will not submit this cookie, and hence, PHP creates a new session for the browser - however the old session technically still exists serverside and can be used or hijacked if any client submits the previous valid cookie for that session.

To have the browser 'notify' your PHP script that it is closing will require javascript hooks like mentioned by pritaeas, which you will need to process to purge/unset the relevant session.

thanks.pritaeas and.TomH.PG..thanks for your thoughts..

im done with substring..

do you have any links for further readings about my questions 1 and 2? i read some other sites but i still dont get the applicable solution.

I have 5th question.

i used firefox in developing my project. but when i open it in internet xplorer, the design was destroyed. why?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.