Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:12:32+00:00 2026-05-22T19:12:32+00:00

I have this website where I can interact with the web both as a

  • 0

I have this website where I can interact with the web both as a logged or anonymus user. When I click a link I call an ajax function:

you click here:

<a id="alcrearuta" class="'.$row->urlamigable.'" href="#">añadir a ruta</a>

This is my ajax function:

var valor=$("#alcrearuta").attr('class');
$("#alcrearuta").click(function(){
    $.ajax({
        type: "GET",
        url: "../ajax/ruta.php",
        data: "urlamigable=" + valor,
        dataType: 'html',
        success: function(data) {
            $("#listaruta").html(data);
        }
    });        
});

The thing is I have two possibilities: either a logged user clicks the link and the ruta.php does its stuff on the database considering the userid that’s set in the session or I have an anonymous user that wants to do something similar.

In my ruta.php I have:

if(!empty($_SESSION['Username'])){
    //Insert stuff on DB
}else{
    //I wish I could create the session here but I can't since it's an ajax call
}

What I need is at some point between the click in the link and the end of the ajax function I can set my $SESSION[‘Username’] variable to get a new value (since the user it’s not logged in, it’s currently empty and thus my inserts on the database not working)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:12:33+00:00Added an answer on May 22, 2026 at 7:12 pm

    if you want to use sessions in php, your php script (ruta.php) schould start with

    session_start();
    

    from that point you can assign any variable to $_SESSION[‘Username’]

    $_SESSION['Username'] = something_to_generate_a_Username;
    

    Just like any other server request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. I am making this website you can see in
I have an website where people can place a vote like this: http://mysite.com/vote/25 This
Hi Guys I have this website: http://www.godfreysammut.com . As you can see in the
I have this website iloveforwards.com created using drupal. I would like to have a
I have this website I am designing and I want to make it to
So I have this website that I'm building and they are wanting to be
I have this ASP.NET/SQLServer2005 website running on a production server (Win2003, QuadCore, 4GB). The
So I have this ASP.Net 2.0 website that uses functions contained within a JS
I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
VS 2008 I have this code snippet I found on a VB website. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.