943,912 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5955
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 3rd, 2007
0

Is session will work if cookies are disbaled on clinet side?

Expand Post »
Hi ,

IF Client disabled the cookies..my question is ..

Will session works in PHP..and if yes how it will work ? and if no what other method to maintain the state of the user.

Thnaks in advance,
mangesh.
Last edited by mangophp; Jul 3rd, 2007 at 10:15 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mangophp is offline Offline
8 posts
since Feb 2007
Jul 3rd, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

You will need to put the session ID in the URL. You will need to make a change in your php.ini file so if you are on a shared host you will need to contact them to see what they will do for you.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 4th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Can you just tell using PHP if a client browser has their cookies enabled?
I would like to just find out and inform them that they need to enable cookies to use the cart on my site.
Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ric1950 is offline Offline
8 posts
since Jun 2007
Jul 4th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

1) Set a cookie

2) Check for that cookie. If you don't see it, then they don't accept cookies.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 5th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Thanks John - I thought of doing that but wanted to know if there was another way.
Ric
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ric1950 is offline Offline
8 posts
since Jun 2007
Jul 5th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Unfortunately that's the only reliable way. If you are going to do that be sure to wait until you are actually going to start the session before doing it. That way users with cookies turned off can still surf the site without being bothered with that message. While doing so they may decide it is worth turning cookies on to do what they need to do.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 7th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Thanks for the reply, John

I have a situation that I can't see any way around - I am posting a page to itself and I would like to inform a visitor that the operation of adding items to their cart did not work as they have not enabled cookies on their browser.

However, I can't see a way of distinguishing between a new visitor to the page with cookies disabled and the reload from a visitor with cookies disabled who hit the "add to cart" button.

Do you have any ideas? The only thing I can think of is of going via a second page which can check if the session is carried forward or a cookie is set and then going back to the original 'page' with:
echo "<body onload=setTimeout(\"location.href='page.php'\",0)>";
but when you do that you get a white screen while that is happening in between the reloads.

I don't know if I can give a link in this forum but I have my page on the internet in a Testing folder if you want to have a look to see what I am trying to do.

Thanks

Ric
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ric1950 is offline Offline
8 posts
since Jun 2007
Jul 7th, 2007
1

Re: Is session will work if cookies are disbaled on clinet side?

As soon as they hit your site set a cookie regardless of what page they enter from. Don't check for it right away though. Some people will just want to browse and that's fine. But as soon as they try to use a feature that requires cookies look for the cookie you set. If it isn't there take them to a page that explains why they need to have cookies enabled.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jul 8th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Click to Expand / Collapse  Quote originally posted by stymiee ...
As soon as they hit your site set a cookie regardless of what page they enter from. Don't check for it right away though. Some people will just want to browse and that's fine. But as soon as they try to use a feature that requires cookies look for the cookie you set. If it isn't there take them to a page that explains why they need to have cookies enabled.
I recommend this method too.
It's simple yet effective, without too much complexity or code to be done.

1) Set a cookie when user visits site.
2) If they try to do something which needs cookies, check if the cookie exists.. if it doesn't they don't have cookies enabled.
Thus take them to the "cookies required" page.

Cheers.

Welldone stymiee, nice logic
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
Jul 8th, 2007
0

Re: Is session will work if cookies are disbaled on clinet side?

Thanks for the replies but unless there is some way of intercepting between when the customer hits the submit button ('Add to Cart') and when the page submits to itself there is no way of knowing if the reload is from the submit button or a new visitor. I see other web sites are linked to this forum so if you want to have a look at my site go to http://www.biodistributors.com.au/Te...les/health.php and disable cookies and see what happens when you try to add items to the cart. The idea is that the "view cart' button doesn't show if the cart is empty. What I am developing now is to show the "view cart' button all the time and when a user who has disabled cookies hits it they get the explanation about cookies needing to be set. Before that the page will just reload unchanged.

Ric
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ric1950 is offline Offline
8 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: image verification problem
Next Thread in PHP Forum Timeline: PHP / IIS / Integrated login w/ home directories





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC