Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aurorame's avatar

drop session if ip changed

How i can drop user session if current IP != auth ip address?

0 likes
3 replies
Snapey's avatar

And throw off mobile users who's IP might randomly change?

aurorame's avatar

@Snapey basic actions normally working just from PC and site not for mobile users. In my case i need to logout (drop user session) if user ip != auth ip (auth IP i store when user make auth)

Snapey's avatar
Snapey
Best Answer
Level 122

@aurorame You will need to write a middleware that tracks the IP. If it is not set in session then set it, then log the user out if it changes,

Not something I would recommend but its your support issues to deal with

Please or to participate in this conversation.