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!
Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.