StefanOnRails's Profile User Rating: -----

Reputation: 35 Craftsman
Active Members
Active Posts:
106 (0.11 per day)
31-July 12
Profile Views:
Last Active:
User is offline Sep 11 2014 10:45 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   StefanOnRails has not set their status

Posts I've Made

  1. In Topic: Programming Tutors Required

    Posted 3 Apr 2013

    Hi oyyou,

    I'm a Javascript / PHP developer and, believe it or not, I actually like your idea. The Web was a great place for me to learn and I kinda owe most of the things I know to the kind people on the internet who decided to share their knowledge with everybody else for free. I think this would be a perfect opportunity for me to give something back to the community that helped me become who I am.

    So, you can count on me. Btw, I'm currently in college so I don't have a lot of free time, but I think I could contribute with 1, maybe 2 videos per week.

  2. In Topic: need help with code about structures

    Posted 31 Mar 2013

    struct highscore
    int score;
    char *name;

    void initializeData (highscore scores[], int size)
    const int noOfChars = 50;
    for (int i = 0; i < size; i++)
    cout << "Enter the name for score # " << (i +1) << ": ";
    scores[i].name = new char[noOfChars];
    cin >> scores[i].name;
    cout << "Enter the score for score # " << (i+1) << ": ";
    cin >> scores[i].score;

    void sortData (highscore scores[], int size)
    bool swap;
    swap = false;
    for (int count = 1; count < size; count++)
    if (scores[count - 1].score < scores[count].score)
    highscore temp;
    temp = scores[count - 1];
    scores[count - 1] = scores[count];
    scores[count] = temp;
    swap = true;

    } while (swap);

    Note: I omitted [code] wrapper so I can emphasize the bold sections
  3. In Topic: Detect if users leave the domain

    Posted 31 Mar 2013

    What are you asking is quite unusual, at least for me. The only idea I have would be to pass a value from page to page via POST method every time the user clicks a link, asking for a new page. Then you can check if the value was set, if not it means the request wasn't sent from one of your pages.

    page template:
    	include 'checker.php';
    	<form id="next-page" action="" method="POST">
    		<input name="session" type="hidden" value="current" />
    	<a class="internal-link" href="page.php">Page</a>
    	<script src="redirect.js"></script>

    	if (!isset($_POST['session'])) {
    		echo 'New Session';
    	} else {
    		echo 'Old session';

    var form = document.getElementById('next-page');
    var addListener = function (element, event, handler) {
    		if (element.addEventListener) {
    			element.addEventListener(event, handler, false);
    		} else if (element.attachEvent) {
    			element.attachEvent('on' + event, handler);
    		} else {
    			element['on' + event] = handler;
    addListener(document.body, 'click', function (event) {
    	var e = event || window.event,
    		target = || e.srcElement;
    	if (target.className === 'internal-link') {
    		if (e.preventDefault) { e.preventDefault(); }
    		else { e.returnValue = false; }
    		form.action = target.href;

    However, there's a major problem in this design and I'm talking about the user ability to change the url via address bar. There's no problem if they want to go on a different website, but if they access another one of your pages a new session is created, even though the user never left the website.
  4. In Topic: Detect if users leave the domain

    Posted 30 Mar 2013

    Well, the session is tied to the lifespan of the browser window. In other words, when user closes the browser the session ends, so there's no need for you to log him out. I don't know any reliable way to detect when the user leaves the website.

    You must understand that the HTTP protocol is stateless. In other words, it doesn't know what happend before the current page was requested. In order to pass data between pages you can use a session, which by the way, once created it injects a cookie on client's computer, cookie which contains the session id (or the name of a tiny file located on your server which holds the user information stored by your scripts). When a page wants to use some session information it looks inside that cookie to get the correct id, then based on that it looks for the corresponding file on the server and retrieves the data.

    When the user clicks a link or changes the url address a request is sent to a server in order to obtain a specific page, which is then downloaded on your local machine by browser. The request however can be sent towards any server, but your scripts are located on YOUR server.
    Plus, even the event of page unloading is hard to track (if possible). However, I can't understand why would you want to log out the user when he leaves the website, but doesn't close the browser window.

My Information

Member Title:
D.I.C Head
22 years old
December 21, 1992
Full Name:
Stefan Baiu
Programming Languages:
PHP, C, C++, C#, Pascal, Java, JavaScript, + HTML, CSS, MySQL

Contact Information

Yahoo  stefanbaiu


StefanOnRails hasn't added any friends yet.


StefanOnRails has no profile comments yet. Why not say hello?