I want to create a popup which is easy, but here's thing, I want to hide it if you become a paid member, and I want it to appear again if you don't subscribe the next month, I am using the paypal button html code and not the ipn, the paypal button is in the account section of the site, well if you want I can put it in the pop-up and i can use the ipn if i have to, instead of the html code just want someone to guide me on how it's done
You're going to need some sort of user authentication to see if someone has purchased your product or not. This should be handled with a server-side language (PHP, Ruby, etc.) and you can change the layout of your page based on whether the user has authenticated or not.
If you don't have any server-side code, you could use cookies that are saved when you receive a successful callback from PayPal, but that isn't going to be very reliable because they won't be found if the user changes browsers or computers.
If you dont want to use a back-end then use cookies. If they have correct values stored in the cookie, use javascript to hide or change the elemts on the page
Related
I am currently redesigning a website and looking for a solution on how to add a paid version of the site.
For example, say I have a <select> drop-down box with 20 elements inside. However, I want 15 of these 20 elements to be disabled unless the user has a paid account. At this time, that is the extent of what I need to differentiate between free/paid versions.
I'm planning on adding the ability to register an account and log in, as well as some type of payment processor (recommendations are appreciated for this! - currently looking at using Django/Python). I just don't know how to best go about managing two different levels of the website, and allowing those additional options to paid members.
I'm working with calculators that are pure Javascript. Using Bootstrap for the page design. As far as anything else goes, I'm open.
To do that, you'd have to add a field with a default value of NULL to your database, let's call it "subscription", into your users table. Then, everytime a user login to your website, fetch the subcription value and write it into a session variable. The last thing you have to do to ensure free members aren't allowed to perform any actions the subscribed members can is checking the content of the session variable while :
building your html, or you could check it on the client side with javascript right after the premium element has loaded (this is for user experience only since a client can remove any html attribute whnever they want)
and
while recieving the data of the premium element on the server side, accept it if the user is premium, reject it if they're free (again, just checking the session variable should do the job).
So as you can see, it's much more about preventing free users to gain access at the paid members options than allowing paid members to browse a completly new version of the website designed specifically for them.
I will try to give you a blunt idea maybe this might help you.
So lets say a user has paid for your service you can flag a token in yours app's backend if a particular user is paid or not. So whenever the user logs in your app next time you can get the status of the logged user.
Once you get the status of the logged user you can enable or disable ui elements.
I hope this made some sense.
I am working on a web application where many people are supposed to connect and one is going to act as an admin. The users can only proceed to the next stage if the admin has allowed the access.
At the moment, I am wondering how should I realize the access control.
In the first version, I was doing an ajax get request when a user clicks the next button, and then if a specific word is present, I proceed. The admin was supposed to modify the page manually. Now I would like to automate it and make it more user-friendly (as the admin does not go to the code manually modifying).
My idea is, there is going to be radio boxes which by clicking, the admin can allow or disallow access. However, to achieve this, my idea was to make an ajax post request to the server when admin selects one and then modifying some keyword in a hidden page. Is this approach feasible or am I completely wrong?
Thank you for your time.
Does the users login first to proceed e.g how they access the system ? A user whom access you wanted to restrict must have something unique associated to it. And you can have his/her data updated upon access update through radio buttons. Any particular user connects to the system only his/her access rights are checked into the system
Okay, so I found a solution to my problem.
First, the hidden page which is only used as a "signal" telling if the users can proceed, renders yes or no. When the Admin selects yes/no radio button, then the app does an ajax post request to my server, saves the value and renders the hidden page with it.
Please be advised, this is not a code-problem question.
I have a resource in my app that is available only for authenticated users. In case a guest user tries to access the resource by clicking on it - registration modal shows up.
Now, I'm building logic using jQuery and PHP in order to store those clicks of guests. However, I also would like to implement something, that will let me retrieve rough information on unique users among the ones who clicked.
The idea I have is this:
When a specific page is loaded, set a JS cookie of "unique" value,
like this: [random string of fixed size][timestamp]. The cookie
would expire in a year from now. If the cookie already exists, don't
do anything.
When the guest clicks on the resource, make an Ajax
call to store the click AND the cookie value.
Later, to get "unique" clicks, make a SELECT that will GROUP BY
the cookie value.
Unless the cookies are cleared or the custom cookie expiration date is exceeded, this should give me a way to determine unique clicks (users) among guests.
I'm interested, if anyone can provide me with a better way to achieve what I need.
I wouldn't reinvent the wheel and use Google Analytics for this kind of task, since it's almost doing al the job and giving you nice graphics and statistics for free.
Here's the scenario. I am developing a one page app:
Most of the operations are achieved through ajax.
The page should show different components in different user login state (admin, normal user, visiter...)
There's so many animations in the page.
Does it mean that it would be necessary to check whether the user has logged in or not each time he clicks a button (some buttons can expand to a menu, whose components are partly shown according to the login state)?
Are there any better possible solutions?
Yes, you should. Only the server knows who should and should not do certain actions. It's mandatory to do checks on the server-side. Never trust the client.
Yes, to be secure you need to make the server authoritatively decide what the client can and CANNOT do. Because javascript is run client side, anyone can modify it and make it run how they want. The server is what you control, and you must use this to ensure that any requests by the client are valid and then follow through on or reject them accordingly.
Servers should almost always be authoritative in this way.
It is probably a good idea to use a UI object (with for example menu options) based on user privileges. Your server side code can return some JSON which includes only menu options that the current user can see and you use that object to construct the front end for that user. So if a user clicks a button to expand a menu you don't have to check anything just display what was returned from the server initially.
You should check permissions every time someone performs a "meaningful" operation in the system such as rename an object or request some data or delete something. This check can be easily built in into your backend API...
I need to build a feature like most of the banks use. Where..
if user has log in to bank account in a browser tab & again he/she change the url of browser & move to some other site.. and again come to bank's page by clicking browser's BACK button.. then bank automatically log out user from there site.
I think may be by java script we can do this.. but, can not able to understand how to do this. I'm using PHP for my server side script. Is this, possible by PHP to do this..
Regards
Suresh
This not a java/PHP question but depends on the exact behaviour you want to implement.
The only way to track the user "live" is through javascript. So if you want to know when the user leaves the page, you can bind yourself to an event listener and then do an ajax call or something like this that invalidates the session on the serverside. Keep in mind that users may be browsing your site with JS disabled, so you need a fallback on the serverside.
I would recommend you to implement session storage on the serverside with a storage mechanism (either the built-in PHP session store or some external storage like Couchbase or Redis, Memached,...) and set the logout time to a sane default (lower if it is something like a banking application).
If you have the basics in place, use JavaScript to enrich the user experience, for example by showing a "countdown" when the user will be logged out and sending session refresh ajax calls to the server to renew the session every time the user has an interaction with the website and such.
For more detailed information I'd need more requirements from your side!