Jump to content

does the session id stay the same every visit?


jwk811

Recommended Posts

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!
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.
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.....

:)

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.