jwk811 Posted January 29, 2007 Share Posted January 29, 2007 I'm making a poll on my site and I wanted to make sure the visitor only submitted one entry. I thought I was take the session_id and his vote and send it to the database and when doing that check to make sure that his session_id doesnt already exist in the database.. would this work? of course the session_id would have to be the same each time he visits so thats the question.. thanks! Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/ Share on other sites More sharing options...
kevinkorb Posted January 29, 2007 Share Posted January 29, 2007 You may want to just check the User's IP address instead.[code=php:0]$ip = $_SERVER['REMOTE_ADDR'];[/code]Session id's change. Or you could set a cookie on the client's machine and do it that way. But then they can clear cookies or not accept them etc. Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171527 Share on other sites More sharing options...
jwk811 Posted January 29, 2007 Author Share Posted January 29, 2007 i thought the id address changed too? does it? Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171530 Share on other sites More sharing options...
matto Posted January 29, 2007 Share Posted January 29, 2007 unless [b]session.cookie_lifetime[/b] is set to anything other than 0 (the default) the session is ended when the user closes the browser.....One thing to remember with using $_SERVER['REMOTE_ADDR'] is that most users have a dynamic IP address assigned every time they connect to the internet...mainly happens with dial-up connections. Broadband users usually have the same IP..... :) Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171533 Share on other sites More sharing options...
jwk811 Posted January 29, 2007 Author Share Posted January 29, 2007 how long do session_ids last? cuz i have this eCart that user session_ids instead of having the visitor make an account... and when you go back later on your shopping cart is still full from before....... i dont get it Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171537 Share on other sites More sharing options...
kevinkorb Posted January 29, 2007 Share Posted January 29, 2007 How sessions work:PHP generates a session id and sets that value as a cookie to the user.The characteristics of the cookie are that it only lasts the browser session. (i.e. in internet expolorer once the browser is closed and re-opened, you will have a new session_id.) Firefox 2 treats sessions differently. I believe they call them persistant sessions. It is possible to stay on the same session from time to time of visiting the page even when closing the browser.Populate your eCart in IE and close the browser. Open it back up and the cart should be empty. If not then its not using a standard session, but probably a hand-rolled solution using a cookie. Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171544 Share on other sites More sharing options...
jwk811 Posted January 29, 2007 Author Share Posted January 29, 2007 i see.. i use aol and you usually leave aol open and just close the windows to each page.. and that was why it was using the same session id.. when i canceled out the aol software/browser and re opened it it didnt work... that sound right? Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171551 Share on other sites More sharing options...
jwk811 Posted January 29, 2007 Author Share Posted January 29, 2007 i think ill try and get the session id the ip address and set a cookie and test them all to lessen the chance since its not really possible to be sure. thanks for your help Link to comment https://forums.phpfreaks.com/topic/36122-does-the-session-id-stay-the-same-every-visit/#findComment-171553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.