LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2010, 09:56 AM   #1
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
How to put a capcha on a page


Besides getting hold of a good software that'll do the job of actually generating the image, I'm confused as to how to actually put it on a webpage- since the program that'll generate the image will be on one particular webpage, and the program that does the *checking* will be on the *subsequent*, i.e. unrelated and separate page, how does it know what the correct letters and numbers are?

I hope I've clarified properly what my question is, if not, just ask

Thanks.
 
Old 03-17-2010, 10:14 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 97
You can use session for it.
 
Old 03-17-2010, 09:33 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
I trust that troop's answer was sufficient for you.

Essentially you can store the details within a session. Remember the session stays on the server and so it is not exposed to the user.

There is a Pear class that does this for you. You may want to check out the documentation.
 
Old 03-18-2010, 09:37 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
Well really this brings us back to the fundamental question of how a session *works*, i.e. what's going *on* behind the scenes if I use PHP to create a session - can anyone explain? I've tried reading a book on the Net about it, but I'm still not clear (as I am unclear about cookies, as well). A session *uses* cookies, right?
 
Old 03-18-2010, 03:51 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
An instance of a session is just a collection of information about that session. The particular collection is identified by a unique value stored in a cookie. Whenever the browser loads a page from a site (domain + path), it sends any unexpired cookies that it has collected for that site along with the HTTP request to the server. The content of the cookie associates that request with session-specific data that is stored on the server. The cookie is in some sense a lookup key to the session data. The server application used to fulfill the HTTP request can then use the data from the cookie to get the session-specific data, and compose the supplied page accordingly.
--- rod.
 
Old 03-18-2010, 08:43 PM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by resetreset View Post
Well really this brings us back to the fundamental question of how a session *works*
The user's browser sends cookies back and forth from the users computer to the server. The default PHP session cookie is called PHPSESSID and an example of what it contains would be 7no1o6s8b42q87si0tcl5jis02. You can check this pointing your browser to a website that uses standard PHP sessions and then view cookies. For Firefox (v3.5.8) go to Tools -> Page Info select the Security tab and then press the View Cookies button.

This cookie gets sent to the server and the contents, in the previous example "7no1o6s8b42q87si0tcl5jis02" will be used by the server to look up a file stored on the server, possibly with the same file name as the content, prefixed with sess_. The location of the session file is given in the php.ini under the session.save_path variable, on my home system it is set to:
Code:
session.save_path = "/var/lib/php/session"
Any value stored for this session will be held in this file. PHP allows you to alter the way sessions work, for example they could be stored on a database, the default cookie name can be modified and the way that the hash is generated can be modified (the default is an MD5 hash string). But generally the default settings are sufficient.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
latex, put \begin{figure*} on own page hedpe Programming 4 11-30-2009 05:16 PM
Apache Question - Automatically put a little banner above every page apache2 Linux - Server 1 01-25-2009 02:22 AM
Put the "Forums" link nice and LARGE on the front page resetreset LQ Suggestions & Feedback 9 06-17-2008 10:43 AM
how to modify ERROR 404 (html) and put my own page?? mandriva 2006 ssarrinah Mandriva 2 06-04-2008 07:26 PM
Put the fix for the most requested fixes for laptops on the front page and... t3gah LQ Suggestions & Feedback 1 03-21-2005 08:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration