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

So I have this website that will be accessed via an SSL connection (
I have a website I've built in VS2005, C#, .NET 2.0. This website does
I have a internal website that users log into. This data is saved as
I think this is pretty typical, you have the same website project with an
I have a web site in asp.net that uses a master page. In this
I have this setup where in my development copy I can commit changes on
I have a website which is displayed to visitors via a kiosk. People can
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

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.