Solved

Cookie set on google chrome doesn't work when using Safari

Posted on 2016-09-25
5
49 Views
Last Modified: 2016-09-25
I am using Chrome to test my registration code. When I register, it sets a cookie valid for 24 hrs so that the person who registered the account has 24 hours to activate their account. If I use google tools I can see that the cookie is definitely set.

When I receive the activation email and click on the link, it takes me to my safari browser as this is my default browser. I then get the message that I set up to say that the activation was unsuccessful because the time expired which is impossible since I did it 30 seconds later. I noticed however that if I copy that link and put it into chrome, it works.

What am I doing wrong? Surely in the real world it doesn't work like this i.e.: if I register on chrome, I can't activate in another browser?
0
Comment
Question by:Black Sulfur
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 41814404
if I register on chrome, I can't activate in another browser?
Using cookies, No, you can't.  Cookies are set in the browser that was used.  They are Not available to any other browser.  Cookies are never shared between browsers.
0
 

Author Comment

by:Black Sulfur
ID: 41814405
I see. So, I basically can't achieve what I want unless I store the time of registration in the database and compare that with the time the user tries to activate their account?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41814411
What is 'normally' done is to include a long hash as a query string to the link in the email.  Such as https://www.mydomain.com/?q=Asjjkqoorllk1928747665mmnnsjhjkckjdjk where the hash is your code to identify the user.
0
 

Author Comment

by:Black Sulfur
ID: 41814414
Yeah, I have that hash but I also want to have a time limit for them to register which is why I wanted the cookie. But as I said, I think I will just store the time of registration in the database and take it from there.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41814421
Sounds like a plan to me.!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question